• Resolved rhf

    (@rhf)


    Hi. I’ve just started using your fine product and am very impressed.

    I am adding an album with multiple galleries to a page with a simple page template. When the user selects one of the galleries, the gallery opens using the same page template. I would like to add a link so the user can return to the original album page, but I don’t what to search for so that I can add conditional logic to the template to display the link.
    Any ideas?
    Thanks.

    https://wordpress.org/plugins/nextgen-gallery/

Viewing 6 replies - 1 through 6 (of 6 total)
  • @rhf, here you can find documentation about conditional tags, and here some hints to create page templates (but if you link the gallery to a page and you have a particular template for that page, you don’t need conditional tags).

    Thread Starter rhf

    (@rhf)

    Thanks, tizz.
    I did a poor job of describing my problem.
    I have an album on a page that consists of several galleries. The page uses a special temple which does what I want. When one of the galleries is selected, it opens on the same page with the same template as the album. This is not too bad, however a link on the gallery page back to the album page would be very desirable. I thought I could do this with some simple logic, but both the album page and the gallery page have the same title and the same permalink, so I don’t know what to test for.

    @rhf, the easy and safe way is to create a template for galleries pages, I’ve tried it just for you and it works well.
    This is if you have the gallery linked to a page.
    Add in that template, just before the content, a thing like this:

    <div id="backtoalbum">
    <a id="return" href="http://mysite.com/albumpage/"><?php print "<< Back to Album" ?></a>
    </div>

    The div and the ids are for assign a style with CSS if you want to, and of course you can change any terms as you want. Remember to assign the template to that page.
    If you don’t have the gallery linked to a page, follow the instructions at the second link in my previous post.
    Put in that template that same code, after <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>
    Then in Gallery settings > basic thumbnails > template, paste the name of your template and save.

    Thread Starter rhf

    (@rhf)

    Tizz,
    Thank you very much for your suggestions. I had sort of given up on an easy solution, and your ideas encouraged me to try again. It turns out that $_SERVER[‘REQUEST_URI’] was what I needed to do the simple logic in my existing template file. That is, I set
    $pos = strpos($_SERVER['REQUEST_URI'], 'nggallery');
    If on the Album page, $pos is false; if one of the galleries is displayed, it is not false. I then use a simple conditional to display the link when a gallery is showing.
    I expect that your solution is much better than mine, but this simple logic is sufficient for my application. Again, I really appreciate your help. Thanks.

    @rhf, I’m glad if you have find the right solution for you.
    Some more explanation – not for you, but for those who would be interested in:
    Last night I forgot to say that after “If you don’t have the gallery linked to a page, follow the instructions at the second link in my previous post” I had to add “until the fourth point”, because this is the case of the gallery not linked to a page, so isn’t possible use the shortcode.
    Also, I’m not sure that putting the name of the template in the settings will work for everyone.
    At last, when a gallery is linked to a page but you prefer the use of IGW button to display it, you can create your template as you would for your child theme, put it in child theme’s folder and choosing it from the dropdown menu.

    Plugin Contributor photocrati

    (@photocrati)

    Thanks, @tizz!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Template file for galleries’ is closed to new replies.