Viewing 10 replies - 16 through 25 (of 25 total)
  • Plugin Author David Lingren

    (@dglingren)

    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.

    Thread Starter Mike Matenkosky

    (@hikinmike)

    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.

    Plugin Author David Lingren

    (@dglingren)

    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

    Thread Starter Mike Matenkosky

    (@hikinmike)

    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?

    Plugin Author David Lingren

    (@dglingren)

    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., https://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:

    https://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

    Thread Starter Mike Matenkosky

    (@hikinmike)

    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.

    Plugin Author David Lingren

    (@dglingren)

    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.

    Thread Starter Mike Matenkosky

    (@hikinmike)

    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… ??

    Plugin Author David Lingren

    (@dglingren)

    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:

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

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

    https://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:

    https://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:

    https://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

    Plugin Author David Lingren

    (@dglingren)

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

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Pagination’ is closed to new replies.