Your Cart

Error displays when used in Drupal theme

These forums are now closed to new replies / tickets.

Please open a support ticket from our new Support page.

Front Page Forums Problems Error displays when used in Drupal theme

  • gravatar
    Eric Bunch
    August 27, 2012 at 2:37 pm

    I’m implementing this on a Drupal theme. We have hundreds of
    pages on our site, but only a handful will have slideshows. So we
    don’t want the following error to appear on each page that doesn’t
    have a slideshow. Can you please let me know how to disable this
    message that displays at the top of the page?

    Init failed: Galleria could not find the element
    “#galleria”.

    Thanks,
    Eric


    gravatar
    Eric Bunch
    August 28, 2012 at 8:41 pm

    Just wanted to follow up on this error. I have a progress
    meeting tomorrow – 8/29 at 3:30pm EST. Can you please give me a
    reply by then, so I can update my team? I would hate for this error
    to be a reason I can’t use your product. And I don’t want to start
    hacking it needlessly, if I can do something simple to fix it.

    Thanks,
    Eric


    gravatar
    Frank
    August 29, 2012 at 8:23 am

    Galleria does not fail silently if the element was not found.
    But you can do something like:

    if ( $('#galleria').length ) {
        Galleria.run('#galleria');
    });
    


    gravatar
    Eric Bunch
    August 29, 2012 at 1:52 pm

    David, you rock. That worked beautifully. Thanks!


    gravatar
    Eric Bunch
    August 29, 2012 at 8:56 pm

    Shoot, I spoke too soon. It does make the error go away, but
    that’s only because it prevents Galleria from loading. Is there a
    way to disable errors completely?

    So you can see what I did, I replaced this

    // Initialize Galleria
    Galleria.run('#galleria');
    

    With this:

    // Initialize Galleria
    if ( $("#galleria").length ) {Galleria.run("#galleria"); });
    

    I tried it with both double & single quotes, but it didn’t
    make a difference.

    Thanks,
    Eric


    gravatar
    Frank
    August 30, 2012 at 9:43 am

    It should work. If length is zero, there is not element called
    “#galleria” on the page.


    gravatar
    Eric Bunch
    August 31, 2012 at 1:10 pm

    Thank you David. Your solution seems like it should have worked,
    but unfortunately I couldn’t get it to work in my Drupal theme, or
    even when trying it in the demo script.

    But I did figure out something that’s working for me that might
    help others using Drupal. I created a new block and pasted in the
    Galleria Initialization JavaScript. Then I placed the block below
    my content, and assigned it to the pages of my website that have
    slideshows on it.

    Thanks again,
    Eric


    gravatar
    Dennis Savai
    November 5, 2014 at 9:49 am

    Thanks for this


Galleria uses cookies to provide necessary site functionality. By using our website, you agree to our Privacy Policy. I understand