WordPress.org

Ready to get started?Download WordPress

Forums

Media Library Assistant
[resolved] Pagination (26 posts)

  1. Mike Matenkosky
    Member
    Posted 1 year ago #

    I have around 80 photos in one gallery. I would like to break that down into 20 per page. Is there a way to do that?

    http://wordpress.org/extend/plugins/media-library-assistant/

  2. Mike Matenkosky
    Member
    Posted 1 year ago #

    On another site, I was using this in my non-MLA gallery:

    [gallery orderby="ASC" numberposts="20" columns="5"]
    
    <!--nextpage-->
    
    [gallery orderby="ASC" numberposts="20" offset="20" columns="5"]

    So I modified it like this. It seems to work. Is there a better way, or is this it? Obviously I'll had to add more nextpage when I need to.

    [mla_gallery orderby="ASC" posts_per_page=20 columns="5" attachment_category="att-category-landscape"]
    
    <!--nextpage-->
    
    [mla_gallery orderby="ASC" posts_per_page=20 offset="20" columns="5" attachment_category="att-category-landscape"]
  3. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Good work! As you've discovered, the [mla_gallery] shortcode supports all the pagination parameters documented in the WP_Query Class Reference.

    On the Settings/Media Library Assistant Documentation tab you can also read "You can also pass "paged=current" to suppress the "nopaging" default; "current" will be replaced by the appropriate value (get_query_var('paged'))."

    Depending on the theme you're using you might find more support for pagination controls (Next, Previous, etc.), but you've got the basic idea.

    Thanks for the update and for your interest in the plugin. If you have any other questions or problems, let me know. In the interim, I'll mark this question Resolved; you can open it back up if you need more help.

  4. Mike Matenkosky
    Member
    Posted 1 year ago #

    One more question related to this. For some background, I'm using one of the http://www.themehybrid.com child themes...highly modified for my photo site. I'm not currently using any lightboxes, so my images display the default 'attachment-image.php'. When I view one image, I see ALL of my thumbnail images below. I would like to only view the thumbnails for on particular gallery (attachment_category). Here is a link to my testing site.

    MLA San Luis Gallery

    I only have 4 images, but when you click on a thumbnail, all of the images that I uploaded to the Media Library (thumnails) show up.

    Is there a way to only display THAT Gallery/Category?

  5. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for sharing the link to your site - your images are beautiful!

    It looks like the tumbnail images at the bottom of your single-image pages are created by some sort of gallery shortcode or logic in the theme you're using (or perhaps another plugin). To be sure, I'd have to look at the source code that generates the page - can you share that with me?

    I have been able to enhance the [mla_gallery] shortcode to work with the Photonic plugin, which also displays galleries and slide shows. It's possible I can do something with the theme and plugins you are using, but I need more information to do some investigation.

    I had a look at the Theme Hybrid web site. I don't have access to the documentation at their site because I am not "an exclusive club member". They have lots of themes (and plugins); which one(s) are you using? If your theme is "highly modified" I may need access to your specific source code.

    If you would rather pursue this offline, send me your e-mail address and I will give you an e-mail address you can use to e-mail me more information. Go to the "Contact Us" page at our web site:

    Fair Trade Judaica/Contact Us

    David

  6. Mike Matenkosky
    Member
    Posted 1 year ago #

    It started out as the 'My Life' theme. It was his personal blog and he used it as the demo on his themhybrid site. He recently changed it, but he didn't update the old theme on the demo. Its more modified in colors, adding slideshow etc, then adding functions. The gallery isn't a plugin, this is just how most of the themes run. Here is the 'attachment-image.php' file from my Child theme:

    I added the Pagination.

    <?php
    /**
     * My own "Tuolumne Meadows" Attachment Template
     *  I added 'prev-next' class and 'comment-template' class, schema.org/Photograph.
     *
     * @package MyLife
     * @subpackage Template
     * @since 0.1.0
     * @author Justin Tadlock <justin@justintadlock.com>
     * @copyright Copyright (c) 2011, Justin Tadlock
     * @link http://themehybrid.com/themes/my-life
     * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     */
    
    get_header(); // Loads the header.php template. ?>
    
    	<?php do_atomic( 'before_content' ); // my-life_before_content ?>
    
    	<div id="content">
    	<?php dynamic_sidebar('papt-image-sidebar'); //Custom Sidebar for  PhotoPress ?>
    		<?php do_atomic( 'open_content' ); // my-life_open_content ?>
    
    		<div class="hfeed">
    
    			<?php if ( have_posts() ) : ?>
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php do_atomic( 'before_entry' ); // my-life_before_entry ?>
    
    					<div itemscope itemtype="http://schema.org/Photograph" id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    
    						<?php do_atomic( 'open_entry' ); // my-life_open_entry ?>
    
    						<span itemprop="name"><?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?></span>
    
    						<div class="entry-content">
    							<?php if ( has_excerpt() ) {
    								$src = wp_get_attachment_image_src( get_the_ID(), 'full' );
    								echo do_shortcode( '[caption align="aligncenter" width="' . esc_attr( $src[1] ) . '" caption="' . get_the_excerpt() . '"]' . wp_get_attachment_image( get_the_ID(), 'full', false  ) . '[/caption]' );
    								}
    								else {
    								echo wp_get_attachment_image( get_the_ID(), 'full', false, array( 'class' => 'aligncenter' ) ) ;
    								} ?>
    							<div itemprop="description" class="attachment-image-desc">
    								<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'my-life' ) ); ?>
    							</div>
    							<div class="prev-next">
    								<div class="prev"><?php previous_image_link( false, '◄ Previous' ); ?></div>
    								<div class="next"><?php next_image_link( false, 'Next ►' ); ?></div>
    							</div>
    							<?php wp_link_pages( array( 'before' => '<p class="page-links">' . __( 'Pages:', 'my-life' ), 'after' => '</p>' ) ); ?>
    							<?php $gallery = do_shortcode( sprintf( '[gallery id="%1$s" exclude="%2$s" columns="10" numberposts="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>
    							<?php if ( !empty( $gallery ) ) { ?>
    								<div class="image-gallery">
    									<h3><?php _e( 'Gallery', 'my-life' ); ?></h3>
    									<?php echo $gallery; ?>
    								</div>
    							<?php } ?>
    						</div><!-- .entry-content -->
    
    						<?php echo apply_atomic_shortcode( 'entry_meta', '<div class="entry-meta">' . __( 'By [entry-author] on <abbr class="published updated" [entry-published] [entry-edit-link before="| "]', 'my-life' ) . '</abbr></div>' ); ?>
    
    						<?php do_atomic( 'close_entry' ); // my-life_close_entry ?>
    
    					</div><!-- .hentry -->
    
    					<?php do_atomic( 'after_entry' ); // my-life_after_entry ?> 
    
    					<?php do_atomic( 'after_singular' ); // my-life_after_singular ?> 
    
    					<div class="comment-template">
    					<?php comments_template( '/comments.php', true ); // Loads the comments.php template. ?>
    					</div>
    
    				<?php endwhile; ?>
    
    			<?php endif; ?>
    
    		</div><!-- .hfeed -->
    
    		<?php do_atomic( 'close_content' ); // my-life_close_content ?>
    
    		<?php get_template_part( 'loop-nav' ); // Loads the loop-nav.php template. ?>
    
    	</div><!-- #content -->
    
    <?php do_atomic( 'after_content' ); // my-life_after_content ?>
    
    <?php get_footer(); // Loads the footer.php template. ?>

    Thought I add this....Only the unattached images display on the bottom gallery regardless of category/tag.

  7. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    I think we're in luck - thanks for posting your source code.

    The key source code statement is this one:

    <?php $gallery = do_shortcode( sprintf( '[gallery id="%1$s" exclude="%2$s" columns="10" numberposts="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

    Let's take this shortcode apart. The id= parameter restricts the gallery to items attached to the attachment's parent post/page. The exclude= parameter excludes the attachment itself. The orderby=ASC parameter is actually an error; perhaps you meant order=ASC. The orderby=ASC will be ignored and you get the default order, which is by menu_order and then post ID in ascending order.

    This statement uses the WordPress [gallery] shortcode to compose the gallery. You can change it to use [mla_gallery] and add the attachment_category="att-category-landscape" parameter to select just the images you want. You can also add orderby=ID order=ASC or whatever sort parameters you need.

    You might have to adjust some of the class, id and CSS attributes to get the gallery formatted properly, but the selection part should be straightforward.

    Let me know how it goes and if you need any more assistance. Thanks again for your interest in the plugin.

  8. Mike Matenkosky
    Member
    Posted 1 year ago #

    The orderby=ASC came from the Parent theme. He used orderby=RAND, so I changed it to ASC.

    Changing the shortcode from this

    <?php $gallery = do_shortcode( sprintf( '[gallery id="%1$s" exclude="%2$s" columns="10" numberposts="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

    to this doesn't work. It obviously removed the gallery thumbnails.

    <?php $gallery = do_shortcode( sprintf( '[mla_gallery id="%1$s" exclude="%2$s" columns="10" numberposts="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

  9. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    With respect to the "orderby" parameter, I can tell you that "orderby=ASC" does not work, and "orderby=RAND" does not work either. I have just re-tested both of these values, and both are rejected by the WordPress [gallery] validation logic.

    However, there is another explanation which isn't good news. I suspect that your theme is intercepting the WordPress [gallery] shortode and substituting its own implementation. There is this bit of code early in the WordPress [gallery] function:

    // Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ( $output != '' )
    	return $output;

    If your theme hooks this filter, then all bets are off.

    I'm not sure what you mean by "It obviously removed the gallery thumbnails", but the HTML tags, class and id attributes and CSS styles in the gallery portion of the page on your test site are quite different than those generated by the WordPress [gallery] shortcode. This is another clue that a different gallery generation function may be generating the gallery.

    When you switch to [mla_gallery] does anything appear? You should see something, even if it's not formatted properly. On a test site, you can try adding "mla_debug=true" to your [mla_gallery] shortcode. This will put out a lot of ugly but informative information. If you can do that, post it here or send it to me and I'll have a look.

    If you have a formatting problem, you can probably use the MLA custom style and markup templates feature to generate a gallery that matches your theme. If it's something else, looking at the debug output might give me more information to help you out.

    Having a look at your theme source code would also be useful. You are welcome to ZIP it up and send it to me if you feel comfortable with that.

    Thanks for sticking with with this; I hope we can resolve it for you.

    David

  10. Mike Matenkosky
    Member
    Posted 1 year ago #

    When I changed this:

    <?php $gallery = do_shortcode( sprintf( '[mla_gallery id="%1$s" exclude="%2$s" columns="10" numberposts="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

    The gallery thumbnails disappeared. Everything else was as it should.

    Here's the results to the debug:

    mla_debug WHERE filter = ' AND ( wp_term_relationships.term_taxonomy_id IN (488) AND tt1.term_taxonomy_id IN (491) ) AND (wp_posts.post_mime_type LIKE \'image/%\') AND wp_posts.post_type = \'attachment\' AND ((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\')))'
    
    mla_debug modified WHERE filter = ' AND ( wp_term_relationships.term_taxonomy_id IN (488) AND tt1.term_taxonomy_id IN (491) ) AND (wp_posts.post_mime_type LIKE \'image/%\') AND wp_posts.post_type = \'attachment\' AND ((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\')))'
    
    mla_debug query = array ( 'attachment_category' => 'att-category-landscape', 'attachment_tag' => 'att-tag-sanluisnwr', 'order' => 'ASC', 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'image', 'nopaging' => true, 'ignore_sticky_posts' => true, 'no_found_rows' => true, )
    
    mla_debug request = 'SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) LEFT JOIN wp_posts AS p2 ON (wp_posts.post_parent = p2.ID) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (488) AND tt1.term_taxonomy_id IN (491) ) AND (wp_posts.post_mime_type LIKE \'image/%\') AND wp_posts.post_type = \'attachment\' AND ((wp_posts.post_status = \'inherit\') OR (wp_posts.post_status = \'inherit\' AND (p2.post_status = \'inherit\'))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC '
    
    mla_debug query_vars = array ( 'attachment_category' => 'att-category-landscape', 'attachment_tag' => 'att-tag-sanluisnwr', 'order' => 'ASC', 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'image', 'nopaging' => true, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'error' => '', 'm' => 0, 'p' => 0, 'post_parent' => '', 'subpost' => '', 'subpost_id' => '', 'attachment' => '', 'attachment_id' => 0, 'name' => '', 'static' => '', 'pagename' => '', 'page_id' => 0, 'second' => '', 'minute' => '', 'hour' => '', 'day' => 0, 'monthnum' => 0, 'year' => 0, 'w' => 0, 'category_name' => '', 'tag' => '', 'cat' => '', 'tag_id' => '', 'author_name' => '', 'feed' => '', 'tb' => '', 'paged' => 0, 'comments_popup' => '', 'meta_key' => '', 'meta_value' => '', 'preview' => '', 's' => '', 'sentence' => '', 'fields' => '', 'menu_order' => '', 'category__in' => array ( ), 'category__not_in' => array ( ), 'category__and' => array ( ), 'post__in' => array ( ), 'post__not_in' => array ( ), 'tag__in' => array ( ), 'tag__not_in' => array ( ), 'tag__and' => array ( ), 'tag_slug__in' => array ( ), 'tag_slug__and' => array ( ), 'suppress_filters' => false, 'cache_results' => true, 'update_post_term_cache' => true, 'update_post_meta_cache' => true, 'posts_per_page' => 10, 'comments_per_page' => '50', 'taxonomy' => 'attachment_category', 'term' => 'att-category-landscape', )

    You can download the Parent Theme here: http://themehybrid.com/themes/my-life

    I appreciate the help trying to figure this out. Honestly, the website that I'm currently using (www.iimagesinthebackcountry.com) works fine. I was thinking of using MLA because I liked some of the features and to maybe make it easier in the long run to add content.

  11. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Mike,

    Thanks for the additional information and the link to your theme. I will try installing the theme and running more tests.

    The debug information you posted is great, but it doesn't match the do_shortcode statement that's just above it in your post. I can see attachment_category and attachment_tag parameters in the debug output but not in the statement.

    Have you tried the statement without any taxonomy parameters, and with just one or the other of the two taxonomy parameters? The two taxonomy parameters are joined by "AND", so an image would have to satisfy both to be displayed.

    I'll continue my investigation.

  12. Mike Matenkosky
    Member
    Posted 1 year ago #

    Unfortunately I don't know what I'm doing, so If I didn't do the debug correctly, please tell me exactly what to do.

    I tried removing the taxonomy parameters, but that didn't work.

    I'm beginning to realize that the MLA isn't going to work in my themes and I will have to do my galleries like I've done in the past. I do hope this isn't the case.

  13. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Mike,

    You did the debug correctly, it just didn't match the example statement.

    I have set up a test site with the "My Life" master and child themes. I have reproduced the "gallery disappears" problem you are having, so I can get to the bottom of what's happening without any further action on your part. I will keep you posted on my progress.

    Thanks for your patience and your cooperation - hang in there!

    David

  14. Mike Matenkosky
    Member
    Posted 1 year ago #

    Glad to hear that it wasn't me.

    Really appreciate all of your help David!

  15. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Mike,

    I've made some progress and discovered that there is a subtle difference in how the "id=" parameter is handled in [mla_gallery] Vs the standard WordPress [gallery] shortcode. It happens with "unattached" images, i.e., images with post_parent=0. I've decided it's a bug in [mla_gallery]; thanks for uncovering it!

    I have also discovered that [mla_gallery] does not process the numberposts parameter, which is not documented for the WP_Query class but the get_posts documentation says "Note: 'numberposts' and 'posts_per_page' can be used interchangeably." This isn't exactly a bug but I'll add support for numberposts in my next release; thanks again!

    If I'm right, adding post_parent=all to your shortcode should make the gallery reappear.

    When you have time, try this statement:

    <?php $gallery = do_shortcode( sprintf( '[mla_gallery post_parent=all id="%1$s" exclude="%2$s" columns="10" posts_per_page="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

    That should produce a gallery similar to the one [gallery] gave you. Leave the attachment_category and attachment_tag parameters out for your first test. If the first test works, add the attachment_category and attachment_tag parameters back in (one at a time, perhaps) and see what happens.

    In my test site, the post_parent=all parameter fixed the id= problem. However, in my site adding the attachment_category and attachment_tag parameters also fixed the problem, without adding post_parent=all. That means there might be some other problem with how [mla_gallery] is working on your site. I tried accessing your sandbox site today but it looks like you're working on it - the "MLA San Luis Gallery" link you gave me no longer works.

    Let me know if these suggestions improve things. If the gallery is still completely missing, put in mla_debug=true and see if the first part of the debug output says "mla_debug empty gallery... ". If it does, then no images satisfy the query. If it doesn't, then [mla_gallery] is generating a gallery that isn't getting displayed for some other reason. Give me a link to the resulting page and I'll have a closer look.

    Thanks for your ongoing help.

    David

  16. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Further investigation reveals that the "My Life" theme does indeed contain a post_gallery filter which replaces the standard WordPress [gallery] shortcode implementation with an alternative function, cleaner_gallery (sound familiar?).

    This alternative implementation does not add inline CSS styles to the page and may generate different HTML markup, e.g., class attributes, that the theme requires for proper gallery display.

    I'm confident that an MLA custom style and markup template can be defined to match the cleaner_gallery output. I will see what I can do...

  17. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    As I expected, it was straightforward to create custom style and markup templates to match the cleaner_gallery implementation.

    The style template is:
    <!-- No inline styles -->

    The markup template has five parts.
    Open:
    <div id='gallery-[+id+]-[+instance+]' class='gallery gallery-[+id+]'>

    Row Open:
    <div class='gallery-row gallery-clear'>

    Item:

    <[+itemtag+] class='gallery-item col-[+columns+]'>
    	<[+icontag+] class='gallery-icon'>
    		[+link+]
    	</[+icontag+]>
    	<[+captiontag+] class='gallery-caption'>
    		[+caption+]
    	</[+captiontag+]>
    </[+itemtag+]>

    Row Close:
    </div><!-- Row Close -->

    Close:
    </div><!-- .gallery -->

    With these templates, the [mla_gallery] output matches the cleaner_gallery output and looks the same on the page.

  18. Mike Matenkosky
    Member
    Posted 1 year ago #

    Sorry it took so long to respond.

    I added the statement back:

    <?php $gallery = do_shortcode( sprintf( '[mla_gallery post_parent=all id="%1$s" exclude="%2$s" columns="10" posts_per_page="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

    What I don't understand is "Leave the attachment_category and attachment_tag parameters out for your first test." Where? If I remove them on the gallery:
    [mla_gallery attachment_category="att-category-landscape" attachment_tag="att-tag-sanluisnwr" numberposts="2"]
    I don't see the images.

    So I didn't remove anything. The thumbnails returned, but no of them match the gallery.

    I don't know why the link didn't work, I've been working on my Smugmug site all day.

  19. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    I'm so sorry - it just occurs to me now that I've been unclear and confusing two uses/occurences of "the gallery"...

    First, there's the original gallery on the "MLA San Luis Gallery" page, the one that's coded:

    [mla_gallery attachment_category="att-category-landscape" attachment_tag="att-tag-sanluisnwr" numberposts="2"]

    Second, there's the "Gallery" at the bottom of the individual image page, the one that's coded (in PHP):

    <?php $gallery = do_shortcode( sprintf( '[mla_gallery post_parent=all id="%1$s" exclude="%2$s" columns="10" posts_per_page="20" orderby="ASC"]', $post->post_parent, get_the_ID() ) ); ?>

    In all of my posts I've been referring to the second "Gallery" and talking about the [gallery] and '[mla_gallery]` shortcodes there. I just assumed that the first gallery was working the way you wanted. No wonder we were confused!

    OK, then, we're making progress. Now that the thumbnails are back at the bottom of the single-image page generated by attachment-image.php you can add the category and tag qualifiers. Try this statement:

    <?php $gallery = do_shortcode( sprintf( '[mla_gallery post_parent=all attachment_category="att-category-landscape" attachment_tag="att-tag-sanluisnwr" id="%1$s" exclude="%2$s" columns="10" posts_per_page="20" orderby=ID order=ASC]', $post->post_parent, get_the_ID() ) ); ?>

    Note the orderby=ID order=ASC parameters; you could also just leave them both out to get the order you want.

    If all goes well you should see thumbnails at the bottom of the page that match the first gallery page, minus the thumbnail for the image displayed in full glory above them. Let me know if that works for you and if I've finally made myself clear.

    Once that's done you can add the custom style and markup templates to reproduce the original appearance of the thumbnails.

    Then, you will ask yourself "how do I avoid hard-coding the attachment_category and attachment_tag values in the PHP statement?" because attachment-image.php is used for all single image displays. There are multiple ways to fix that, and I can work that through with you if you need help.

    David

  20. Mike Matenkosky
    Member
    Posted 1 year ago #

    Didn't expect an answer so late!

    That worked!

    I created a custom style/markup like on your previous post, and it worked like a charm (no surprise). As far as showing JUST the attachment_category and attachment_tag parameters...I will definitely need help with that. Filter page ID with category/tags?

  21. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    That's excellent; we're in the home stretch!

    Thinking through your requirements suggested a couple of MLA enhancements that will make the solution easier and more general. I have implemented and tested them and I will release a new MLA version, 1.20, in a day or so. When you upgrade to v1.20 you can make the changes below and you should be all set.

    The goal is simple; pass the attachment_category and attachment_tag values from the original gallery on the "MLA San Luis Gallery" page to the single-image page, then use them in the PHP do_shortcode statement in the attachment-image.php file to filter the thumbnail gallery at the bottom of that page.

    The first part of the solution extends the [mla_gallery] shortcode in the "MLA San Luis Gallery" page. The new shortcode reads:

    '
    [mla_gallery attachment_category=att-category-landscape attachment_tag=att-tag-sanluisnwr mla_link_href="{+link_url+}&attachment_category={+query:attachment_category+}&attachment_tag={+query:attachment_tag+}"]
    '

    The mla_link_href parameter is new in v1.20, and it lets you change the link behind each image in the gallery. The {+link_url+} argument is replaced by the standard value, e.g., http://sandbox.imagesinthebackcountry.com/?attachment_id=1927. To this link we add the extra information we're passing to the single-image page. The & might get changed to an HTML Entity (amp;) by WordPress' visual editor. The {+query:attachment_category+} argument pulls the value out of the shortcode parameters and puts it in the link; same for the last argument. The query: feature is another v1.20 enhancement.

    After the substitutions, the links will become something like this example:

    http://sandbox.imagesinthebackcountry.com/?attachment_id=1927&attachment_category=att-category-landscape&attachment_tag=att-tag-sanluisnwr

    On to the second part; using the new information to filter the thumbnail gallery on the single-image page(s). Here we modify the PHP code to detect the incoming information and generate an [mla_gallery] when both parameters are present. If the parameters are not there, the original PHP code with the standard [gallery] statement is used instead. That prevents problems when the single-image page is invoked from some other part of your site. The new PHP code looks like this:

    <?php if ( isset( $_REQUEST['attachment_category'] ) && isset( $_REQUEST['attachment_tag'] ) ) {
    	$gallery = do_shortcode( sprintf( '[mla_gallery exclude="%1$s" columns="8" numberposts="16" mla_style=cleaner mla_markup=cleaner attachment_category="%2$s" attachment_tag="%3$s" mla_link_href="{+link_url+}&attachment_category={+query:attachment_category+}&attachment_tag={+query:attachment_tag+}"]', get_the_ID(), $_REQUEST['attachment_category'], $_REQUEST['attachment_tag'] ) );
    } else {
    	$gallery = do_shortcode( sprintf( '[gallery id="%1$s" exclude="%2$s" columns="8" numberposts="16" orderby="rand"]', $post->post_parent, get_the_ID() ) );
    } ?>

    Quite a handful, but straightforward. The if ( isset( ... test ensures that the filtered [mla_gallery] is only used when both arguments are present. The mla_style and mla_markup parameters grab the custom templates you've coded up; use whatever names you gave them in place of "cleaner". The attachment_category="%2$s" and attachment_tag="%3$s" parameters pass the new information into the thumbnail gallery shortcode using the $_REQUEST values at the end of the statement. The mla_link_href parameter makes another appearance, this time to make sure the links behind the thumbnail images pass the filter information on to subsequent single-image pages.

    That's it. If you change the original gallery page and the PHP code in the attachment-image.php file you should be done. I've made a few other changes to the PHP code above, so compare your final code carefully to my example.

    As I said, look for the new MLA v1.20 release and upgrade to it before you make these changes. If you have any problems or further questions, let me know.

    Responding to questions and issues like this are one of the main sources of MLA enhancement ideas, and I always learn a lot in the process of working through them. I'd like to thank you again for your interest, your help and your patience as we got to what I hope is a good result.

    David

  22. Mike Matenkosky
    Member
    Posted 1 year ago #

    I was going to ask about using a 'if else' because I didn't like the idea of not having the original[gallery] code on the attachment-image.php page. Good work!

    I'll be looking forward to the update! Again, REALLY appreciate your hard work with this plugin. Glad I didn't have to scrap that idea.

  23. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Version 1.20 has been released; let me know if you'd like any more help with your application.

    I'm going to mark this issue resolved fo now, but you can re-open it if something else comes up.

    Thanks for the kind words and for your continuted interest in the plugin.

  24. Mike Matenkosky
    Member
    Posted 1 year ago #

    It works except for the "RETURN TO ENTRY". I didn't check it as we were going through some of the other issues. It should bring a viewer back to the Gallery page. Wouldn't mind having a breadcrumb that shows the current gallery. Right now it shows "Home > 'image'. Would like to see Home > 'current category/gallery' > 'image'. But I really nead the other to work.

    Sorry... :(

  25. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Mike,

    The "RETURN TO ENTRY" issue is related to your theme, not to [mla_gallery]. If you look at the other galleries in the "Portfolio" section of your site, they all have URLs like:

    http://sandbox.imagesinthebackcountry.com/portfolio/merced-nwr/merced-nwr-at-surise/

    The link you gave me to your "MLA San Luis Gallery" is:

    http://sandbox.imagesinthebackcountry.com/mla-san-luis-gallery/

    You can see that it's not under the "portfolio" parent. Also, the links within the gallery to single images look like:

    http://sandbox.imagesinthebackcountry.com/portfolio/yosemite-1/portfolio-test-1/attachment/the-lonely-road/

    But the links in the "MLA San Luis Gallery" are in the WordPress standard form, i.e., they start with ?attachment_id=1931. For example:

    http://sandbox.imagesinthebackcountry.com/?attachment_id=1931&attachment_category=att-category-landscape&attachment_tag=att-tag-sanluisnwr

    All of the site navigation links in your site are generated by theme-specific functions like do_atomic and do_atomic_shortcode. I suspect that all the portfolio links are generated by the theme as well.

    I'm happy to work with you on issues related to the theme, but that's not a subject for the MLA support forum. If you want to pursue this discussion offline, send me your e-mail address (or telephone number) and I will respond to continue the dialog. Go to the "Contact Us" page at our web site:

    Fair Trade Judaica/Contact Us

    Thanks for understanding.

    David

  26. David Lingren
    Member
    Plugin Author

    Posted 11 months ago #

    The "Pagination Revisited" topic now contains quite a bit of good information for these issues.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags