Support » Plugin: jQuery Colorbox » [Plugin: jQuery Colorbox] Colorbox working from shortcode NGG but not from PHP

  • Resolved zsero

    (@zsero)


    I am trying to integrate Nextgen and Colorbox in a PHP template.

    My problem is that when I just normally insert a [nggallery id=8] it inserts a gallery and Colorbox works perfectly on this, with previous and next relations, etc.

    However when I try to insert it from PHP template it doesn’t work.

    So while:
    [nggallery id=8] works when written on a page, neither

    echo nggShowGallery( 8, '' );
    nor
    echo do_shortcode('[nggallery id=8]');

    works in PHP. It’s very strange and I don’t understand what is happening. What is the difference between [nggallery id=8] and echo do_shortcode(‘[nggallery id=8]’); that one triggers Colorbox while the other doesn’t? Of course I can force Colorbox to all images, but then I loose the previous <> next relations.

    Did anyone experience something similar? If yes, did you find a solution?

    http://wordpress.org/extend/plugins/jquery-colorbox/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor techotronic

    (@techotronic)

    The HTML output must somehow be different.
    Do you have an example page I could have a look at?

    Cheers,
    Arne

    Thread Starter zsero

    (@zsero)

    Yes, the HTML is different.

    When I insert using PHP, the “colorbox-ID” class is not added to the HTML. When I insert using WP page editor, it is added perfectly.

    When I force colorbox for all images then colorbox-single gets added, but then it doesn’t work as a gallery.

    I have saved a complete HTML version from both versions here:
    http://dl.dropbox.com/u/3344128/php-wp-insert.zip

    Plugin Contributor techotronic

    (@techotronic)

    ah, yes, that’s it…
    Shortcodes are added using the richtext editor and are evaluated before the richtext filters kick in. I use a richtext filter to add the “colorbox-ID” class to images.

    The only way to add the CSS class to images outside of the richtext is by using JavaScript. Since then I can’t really decide where on the page the image is (and the ID of the post/page is unknown), the CSS class “colorbox-single” is added, which is not grouped.

    Cheers,
    Arne

    Thread Starter zsero

    (@zsero)

    Can you tell me what is the JS what I should include in the gallery template page?

    Or alternatively, why does the rel=”colorbox-setX” not work? I thought it’s the standard way for colorbox to work and I can manually specify it in NextGen, using the option panel for it.

    View post on imgur.com

    Could you make a version which parses the rel values, just like the original Colorbox?

    Thread Starter zsero

    (@zsero)

    Here is a link to the working gallery:
    http://kozossegikertek.hu/hir/ebreszto-ilyen-volt/

    and here is one for the non-working one (from template):
    http://kozossegikertek.hu/galeria/ebreszto-eloadasok-es-parcella-sorsolas/

    Here is what I wrote in the custom Nextgen setting:
    rel="colorbox-%GALLERY_NAME%"

    Plugin Contributor techotronic

    (@techotronic)

    my plugin does not use the “rel” attribute since it is not legal to use an arbitrary value in that attribute and it is meant to be used for something else entirely.
    See w3schools for a reference.

    Just add “colorbox-123” or some other number as the CSS class. Images with the same number will be grouped, otherwise it does not matter which number you put in.

    inserting the NGG Gallery variable %GALLERY_NAME% will only work if your gallery names only contain numbers.

    Cheers,
    Arne

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: jQuery Colorbox] Colorbox working from shortcode NGG but not from PHP’ is closed to new replies.