Forum

Thread tagged as: Question, Gallery, Problem

How do I create a link field to add a url to a gallery image. AND TO GET THE GAL...

I am setting up a masonry gallery grid and I would like it that when the viewer clicks on an image tile; it directs them to that particular page assigned to the image. I would like it that I can customize in the control panel where that image would link to, for that particular image tile.

Can someone tell me what to add to the code below,if this is even correct so far; in order to get this clickable as a URL.

This is my "image.html" file which lives in perch/templates/gallery

<perch:gallery id="image" type="image" key="main"  width="640" height="480"/>

This is my album-image.html which also lives in perch/templates/gallery

<li><a href="album.php?s=<perch:gallery id="url""><img src="perch:gallery id="main"">
  <div><span>
    <?php perch_content('Gallery description'); ?>
    </span>
    <h5>–view–</h5>
  </div>
  </a> </li>

The album-image.html is the file I use in my layout template below.

<ul class="grid effect-2" id="grid">
<?php perch_gallery_album_images("portfolio", array( 'template'=>'album-image.html' )); ?>
</ul>

I have created a gallery called portfolio and added images to it. It fails to populate the page with the gallery. When I check the code in chrome developers tools, I see up to the code below.

<ul class="grid effect-2" id="grid" style="position: relative;">
</ul>

Would love some help sorting this out.

M

Mark Chen

Mark Chen 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The first thing that stands out is you appear to have page functions like perch_content() inside your template files. That won't work. You use page functions in pages, and template tags (like <perch:gallery ... /> and <perch:content ... />) in templates.

Take a look at this video about Gallery and see if that helps you frame things. https://docs.grabaperch.com/video/v/gallery-a-simple-portfolio/

Thats the actual video I was following.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

That video doesn't put perch_content inside template files, so perhaps take another look and make sure you are using the files correctly.