Viewing 15 replies - 1 through 15 (of 31 total)
  • Thread Starter johanna2patricia

    (@johanna2patricia)

    Can somebody please shed some light on this?
    When you have more than 1 gallery on a page, the thumbnails seems to be created with the same name and therefore creating all those duplicate ID’s.
    There must be a way to change that?
    https://www.patriciakaas.nl/blog/

    Johanna

    I’m also curious if this is an issue that can be solved. Maybe including the galley name into the id somehow? Or maybe an option not to have the ID’s display in the markup?

    I know this is an old topic however I’ve just managed to correct this issue.

    You will need to create a template Click here (scroll down to the HOW TO CREATE YOUR OWN TEMPLATES section)

    Follow the instructions there and when you have the new template setup look for the opening ngg-image div. (around line: 41) place this as the id

    ngg-image-<?php echo $gallery->ID .'-'. $image->pid ?>

    This will give you the gallery ID then the image ID so you won’t have any duplicate IDs. Next step is to fix the pagination though…

    Thread Starter johanna2patricia

    (@johanna2patricia)

    Kieranmcclung, I am cetainly going to try this. If this works you are a legend!
    I will let you know how it goes.

    Johanna

    Thread Starter johanna2patricia

    (@johanna2patricia)

    I tried it, but I still get the duplicate id’s.
    I created a new template: gallery-template.php
    I changed line 41 to:
    <div id="ngg-image-<?php echo $gallery->ID .'-'. $image->pid ?>" class="ngg-gallery-thumbnail-box" <?php echo $image->style ?> >
    I put the new template in the new nggallery folder, that I put in my themes folder.
    And I used these shortcodes:
    [nggallery id=1 template=gallery-templatename]

    [nggallery id=2 template=gallery-templatename]

    [nggallery id=3 template=gallery-templatename]

    What am I missing here?
    This is my testpage: https://www.libralion.com/blog/test/

    Johanna

    Plugin Contributor photocrati

    (@photocrati)

    @johanna2patricia – If this is your specific shortcode [nggallery id=1 template=gallery-templatename] then I would try changing the template parameter to this:
    [nggallery id=1 template=template]

    Although I would probably also recommend using a different less generic template name such as gallery-fix-duplicates.php and then use:
    [nggallery id=1 template=fix-duplicates]

    – Cais.

    PS: If this proves out it will be going to our developers to review immediately.

    Thread Starter johanna2patricia

    (@johanna2patricia)

    Hi Cais,
    I changed the shortcode to: [nggallery id= 1 template=template], but that doesn’t work.
    I get “not a valid template name” then.

    Johanna

    Plugin Contributor photocrati

    (@photocrati)

    @johanna2patricia – Try renaming the template as I recommended … it may be something in the Legacy code that does not like “template” as the template name (although it should work it may be worth reviewing all the same).

    – Cais.

    Thread Starter johanna2patricia

    (@johanna2patricia)

    Ok renamed the template to: gallery-fix-duplicates.php
    And then the shortcode: [nggallery id=1 template=fix-duplicates]
    But still all these duplicate id errors.
    kieranmcclung how did this work for you? Can you help us out here?

    Johanna

    Plugin Contributor photocrati

    (@photocrati)

    @johanna2patricia – Did you clear out your image cache under Gallery > Other Options > Miscellaneous (you might need to clear your browser caches as well)?

    – Cais.

    PS: Looking at your test page the IDs do appear different as they contain a dynamic string reference now which will solve you issues provided you do not call images more than once from the same album.

    PPS: This will likely serve as a work-around rather than a solution as it is still potentially possible to present duplicate ID under this code.

    Thread Starter johanna2patricia

    (@johanna2patricia)

    Yes I cleared all caches. But still all those ID errors.
    I hope kieranmcclung will come to the rescue. If he has solved it, I hope he can let us know what I am missing here.

    Johanna

    Hello Johanna,
    I saw your tweet and came rushing over, hopefully I can help.

    It seems you have created the gallery perfectly fine. What I did now was go to the Gallery Settings and select NextGen Basic Thumbnails. In here I could select the template and apply it to all galleries. You can even just visit this area to ensure that your template is there. It’s listed as Parent Theme: gallery-[template_name].php

    I’m using the add gallery button in the content editor to add the gallery, rather than a short code.

    Where things might differ is if you’re using a different gallery in which case I can only assume they use different templates. All you would need to do though would be to place the ngg-image-<?php echo $gallery->ID .'-'. $image->pid ?> as the ID.

    Let me know if you need any more help though.

    Thread Starter johanna2patricia

    (@johanna2patricia)

    Hi Kieran,
    Thanks for your answer. I did what you suggested.
    The galleries work fine, but the problem is that there is still the problem with the duplicate id. And that was the main reason for this post.
    Did you test it yourself with more than 1 gallery?

    Johanna

    Thread Starter johanna2patricia

    (@johanna2patricia)

    BTW I did what Cais suggested and used gallery-fix-duplicates.php
    And then the shortcode: [nggallery id=1 template=fix-duplicates]

    Johanna

    Thread Starter johanna2patricia

    (@johanna2patricia)

    In the source of my testpost it seems ok, but when I use the validator I get all those errors: https://validator.w3.org/check?uri=http%3A%2F%2Fwww.libralion.com%2Fblog%2F

    Johanna

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Duplicate ID ngg-image-0’ is closed to new replies.