Page 1 of 1
[SOLVED] Gallery Problem
Posted: Fri Aug 23, 2013 1:32 pm
by delve2013
Is there anyway I can make each gallery image clickable as a link to an internal page on my site?
I have the gallery setup using some jquery which makes each image slide or fade from one to another, ideally I want each image or banner to be wrapped inside a link.
Is this possible?
Re: Gallery Problem
Posted: Fri Aug 23, 2013 1:48 pm
by velden
Yes it is add a custom field (attached to images) and ask for page alias.
Then use that value inside the Gallery template you use to build the link.
However, if it's 'just' a slider you might consider using another module for it.
ListIt2 might be a good option because it has the option to add a page dropdown list (so editors don't need to know about alias but just select a page).
Combined with CGSmartImage module you could make sure images are resized to the proper width and height.
Re: Gallery Problem
Posted: Fri Aug 23, 2013 2:34 pm
by delve2013
so this is my template code:
Code: Select all
<div id="slides">
{foreach from=$images item=image}
{if !$image->isdir}
<img src="{$image->thumb}" alt="{$image->titlename}" />
{/if}
{/foreach}
</div>
<a id="prev" href="#">Prev</a>
<a id="next" href="#">Next</a>
Can you please give me an example of how I would use a custom definition here?
Re: Gallery Problem
Posted: Fri Aug 23, 2013 2:48 pm
by velden
Add a Field Definition called 'targetpage', apply field for: images and check 'public' (not sure if that's required).
Type page ALIAS in the field for all images.
Then change code:
Code: Select all
<div id="slides">
{foreach from=$images item=image}
{if !$image->isdir}
<a href="{cms_selflink href=$image->fields.targetpage.value}">
<img src="{$image->thumb}" alt="{$image->titlename}"
/>
</a>
{/if}
{/foreach}
</div>
<a id="prev" href="#">Prev</a>
<a id="next" href="#">Next</a>
Didn't test this.If it does not work maybe you could change one line to:
Code: Select all
<a href="{cms_selflink href="`$image->fields.targetpage.value`"}">
(where ` is a backtick NOT single quote)
Note that the NAME of the field not per se is the same as the ALIAS of the field. In the code you should use the alias, which is visible after adding the Field Definition
Re: Gallery Problem
Posted: Fri Aug 23, 2013 2:54 pm
by delve2013
You are a legend, it worked perfectly!
Thank you

Re: [SOLVED] Gallery Problem
Posted: Tue Mar 11, 2014 11:30 am
by delve2013
If I wanted to change the target page to a full url how would I do that?
Re: [SOLVED] Gallery Problem
Posted: Tue Mar 11, 2014 11:43 am
by velden
delve2013 wrote:If I wanted to change the target page to a full url how would I do that?
Not sure what the question is:
- do you want to be able to type a full url in the custom field with each image?
- if so, do you want to be able to type an alias in stead too?
- ...?