Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter CHQue

    (@chque)

    Hi David,

    You’re right, I found the solution on this very topic. I was surprised wordpress misunderstood my shortcode even in the “text” editor. Anyway, everything is fine now.

    Thanks

    Thread Starter CHQue

    (@chque)

    Ok that’s stupid but surrounding my shortcode with markups even if I'm using the text editor solved my issue but now I've got ugly markup in my html. Is there another way do proceed my request other with the tax_query ?

    Thread Starter CHQue

    (@chque)

    Hi again,

    Please find below my shortcode :
    [mla_gallery itemtag="div" captiontag="p" post_mime_type=all post_parent=all link=file columns=1 orderby=title mla_markup="major-custom-template" my_filter="format terms" tax_query="array(array('taxonomy' => 'pays','field' => 'slug','terms' => 'regional-aoc'))"]

    I also tried with the ID rather than the slug :
    [mla_gallery itemtag="div" captiontag="p" post_mime_type=all post_parent=all link=file columns=1 orderby=title mla_markup="major-custom-template" my_filter="format terms" tax_query="array(array('taxonomy' => 'pays','field' => 'id','terms' => '66'))"]

    Finally tried to change post_parent=all to post_parent=current but nothing seems to work and I always got the following error :

    ERROR: Invalid mla_gallery tax_query = ‘terms ?’

    Thread Starter CHQue

    (@chque)

    Hi David,

    I shouldn’t open a new topic on this page but I don’t know how to filter the mla_gallery with specific term of my custom taxonomy… I tried tax_queries and other solution but it doesn’t work (either 0 or all documents are displayed).

    Can you help me to update my shortcode above (in previous post) but showing only documents based on my custom taxonomy = pays and term = regional-aoc

    Thanks a lot and have a good day!

    Thread Starter CHQue

    (@chque)

    Hi David!

    No I didn’t got your email but unfortunately I deleted the code from my functions.php file and I don’t think I’ll be able to retrieve it… ??

    Anyway, I want to thank you again for your help and your patience resolving my issues ??

    Cheers,
    Quentin

    Thread Starter CHQue

    (@chque)

    Hi David,

    Great news, I’ve tried to add your code to the mla-hooks-example.php file rather than in my functions.php file and guess what… it works perfectly ??

    Thanks again for your help
    Quentin

    Thread Starter CHQue

    (@chque)

    Hi David,

    Unfortunately I’ve got no message so I guess something is wrong.
    I’ll send you my functions.php by email in few minutes.

    Thanks

    Thread Starter CHQue

    (@chque)

    Hi David and thanks for your answer.

    You’re right, I’ve got now 2 mla_gallery on my home page and I used your custom markup between my previous post and your answer to turn the itemtag and icontag into <div> and the captiontag into a <p>.

    If you’re looking closer at the two mla_gallery, the first one is generated with my custom taxonomy (alea, thematique, etc…) as class and the second one is generated with tags attached to the media as an id (I’ve created my tags based on my custom taxonomy slugs).

    The idea behind this two galleries (and to use the same taxonomy slugs for categories and tags) is to provide to the filters on the left results in 2 levels : the media matching the filter with their class are strongly relevant and the media matching the filter with their id are less relevant but still interesting for the user. I don’t know if this explanation is clear but I hope it helps you to understand a little bit more this project.

    Anyway, the custom markup are working well. I’ve created one to generate mla_gallery with class and another one with id. Please find below my current shortcodes for the home page

    [mla_gallery itemtag="div" captiontag="p" post_mime_type=all post_parent=all link=file columns=1 orderby=title mla_markup="class-custom-template"]
    [mla_gallery itemtag="div" captiontag="p" post_mime_type=all post_parent=all link=file columns=1 orderby=title mla_markup="id-custom-template"]

    I also changed my functions.php with your code but it still doesn’t work and I don’t have any error message ?? What other material can I share with you to help you to find a solution ?

    Thanks again for your help and your time, it’s always a pleasure to share with you.
    Cheers

    Thread Starter CHQue

    (@chque)

    Hi again David.

    Quick question, is there a way to easily add the class generated by the mla_link_class shortcode to the <figure> markup rather than the link ?

    Thanks for your feedback
    Quentin

    Thread Starter CHQue

    (@chque)

    Hi David and happy new year ??

    I add your code into my functions.php and had the following errors:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'MLAGalleryHooksExample' not found in /home/httpd/vhosts/unicef.upwelling.net/undp.upwelling.net/demo/wp-includes/plugin.php on line 213

    Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/unicef.upwelling.net/undp.upwelling.net/demo/wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 362

    I’m not a php expert but to solve it I replaced
    add_filter( 'mla_gallery_item_values', 'MLAGalleryHooksExample::mla_gallery_item_values_filter', 10, 1 ); by add_filter( 'mla_gallery_item_values', 'mla_gallery_item_values_filter', 10, 1 ); but the code is still not working because it still display the taxonomy terms rather than the taxonomy slugs

    Can you help me one more time please and BTW you can now check it on https://undp.upwelling.net/demo/

    Thanks!

    Thread Starter CHQue

    (@chque)

    Hi David and thanks for your answer,

    Here’s my current mla_gallery shortcode : [mla_gallery post_mime_type=all post_parent=all link=file columns=1 orderby=title mla_link_class="{+terms:alea+}{+terms:thematique+}{+terms:type_doc+}{+terms:pays+}"]

    You’re right, I’ve got multiple terms and they are comma-separated but it also display their name rather than their slug (for example : class=”alerte précoce” rather than “class=”alerte-precoce”).

    Can you help me on both point ? I’d be glad to test your next version but I have to show the demo tomorrow so can you send me the php code I have to add to my functions.php.

    Thanks a lot again
    Cheers from Switzerland ??

    Thread Starter CHQue

    (@chque)

    Hi David and thanks for your support.

    I’ve checked the “Support” section and the “Media / Assistant” tab and everything is fine.
    In fact, when I said “doesn’t work at all”, I actually meant that either my “class” is empty in my HTML code or I’ve got a “class=’la taxonomie n’est pas valide'” (unvalid taxonomy in english) mainly because I don’t know what shortcode to use in my [mla_gallery] bracket.

    My last attempt was [mla_gallery post_mime_type=all post_parent=all link=file columns=1 orderby=title mla_link_class="{+terms:category+}"] but with this shortcode my class is empty ?? I guess it’s because I’m not using att_categories but custom ones built in my children theme’s functions.php

    I’m currently migrating my demo and it will be online tomorrow. I hope these few lines can already give you a clue but if not, I’ll send you more details when my demo is online ??

    Thanks again
    Quentin

    I’m really interested in this feature too. Anyone to help us here ?
    Thanks

    Thread Starter CHQue

    (@chque)

    Just for your information, you’ve got a tiny error in your code. You typed 10240 rather than 1024.

    Here’s the corrected code :

    public static function mla_gallery_item_values_filter( $item_values ) {
        /*
         * For this example, we will reformat the 'date' value as d/m/Y. We use a shortcode parameter of our
         * own to do this on a gallery-by-gallery basis, leaving other [mla_gallery] instances untouched.
         */
        if ( isset( self::$shortcode_attributes['my_filter'] ) && 'format date' == self::$shortcode_attributes['my_filter'] ) {
    
            /*
             * Default format is YYYY-MM-DD HH:MM:SS (HH = 00 - 23), or 'Y-m-d H:i:s'
             * Convert to UNIX timestamp so any reformat is possible
             */
            $old_date = $item_values['date'];
            $timestamp = mktime( substr( $old_date, 11, 2 ), substr( $old_date, 14, 2 ), substr( $old_date, 17, 2 ), substr( $old_date, 5, 2 ), substr( $old_date, 8, 2 ), substr( $old_date, 0, 4 ) );
    
            /*
             * Update the $item_values and pass them back from the filter.
             */
            $item_values['date'] = date( 'd/m/Y', $timestamp );
    
    		/*
    		 * Compose the file size in different formats.
    		 *
    		 * You can use MLAOptions::mla_get_data_source() to get anything available.
    		 */
    		$my_setting = array(
    			'data_source' => 'file_size',
    			'option' => 'raw'
    		);
    		$file_size = (float) MLAOptions::mla_get_data_source($item_values['attachment_ID'], 'single_attachment_mapping', $my_setting, NULL);
    		if ( 1048576 < $file_size ) {
    			$file_size = number_format( ($file_size/1048576), 3 ).' MB';
    		} elseif ( 1024 < $file_size ) {
    			$file_size = number_format( ($file_size/1024), 3 ).' KB';
    		} else {
    			$file_size = number_format( $file_size );
    		}
    
            /*
             * Compose a new caption with a "clickable" document title, date and file size.
             */
            $item_values['caption'] = sprintf( '<a href="%1$s">%2$s</a> <span class="info"><a href="%1$s">%3$s | Size: %4$s</a></span>', $item_values['file_url'], $item_values['title'], $item_values['date'], $file_size );
    
        }
    
        return $item_values;
    }
    Thread Starter CHQue

    (@chque)

    Thank you so much David and don’t worry about the delay to find the error. You did a great job ??

Viewing 15 replies - 1 through 15 (of 20 total)