• Resolved gmunoz

    (@gmunoz)


    A simple hack to make images in a specific gallery link to a page.

    Under your alttext field in the gallery, enter the url.

    Copy the gallery.php template.

    Within your gallery-copy.php template, change the following:

    <a href="<?php echo $image->imageURL ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >

    to

    <a href="<?php echo $image->alttext ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >

    When you enter the short code in a page, add the template:

    [nggallery id=x template=copy]

    I’m pretty new to php, but this seems to work in a way that allows you to have galleries with links and galleries with singlepic in the same blog.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Great hack! Thanks a lot, you saved my day!

    I made some dirty improvements, because I wanted to use “alttext” and link to a page at the same time.
    Enter your alternative text and URL separated by the “#” character.
    Replace the mentioned lines in gallery-copy.php to

    <?php $a = explode("#", $image->alttext, 2);
    if (empty($a[1])) { ?>
    <a href="<?php echo $image->imageURL ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
    <?php } else { ?>
    <a href="<?php echo $a[1] ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
    <?php } ?>
    	<?php if ( !$image->hidden ) { ?>
    		<img title="<?php echo $a[0] ?>" alt="<?php echo $a[0] ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
    	<?php } ?>
    </a>

    Besides the nggallery short code, you can also insert [album id=2 template=extend] to be able to navigate in an album. For this in nggfunctions.php->function nggShowAlbum you can change the line
    $out = nggShowGallery( intval($gallery) );
    to
    $out = nggShowGallery( intval($gallery), 'copy' );
    to hardcode the usage of the gallery-copy.php template.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘NextGEN Gallery Template — Image Link’ is closed to new replies.