[SOLVED] Gallery Problem

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
delve2013
Forum Members
Forum Members
Posts: 91
Joined: Thu Jan 31, 2013 4:23 pm

[SOLVED] Gallery Problem

Post 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?
Last edited by delve2013 on Fri Aug 23, 2013 2:54 pm, edited 1 time in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Gallery Problem

Post 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.
delve2013
Forum Members
Forum Members
Posts: 91
Joined: Thu Jan 31, 2013 4:23 pm

Re: Gallery Problem

Post 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?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Gallery Problem

Post 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
delve2013
Forum Members
Forum Members
Posts: 91
Joined: Thu Jan 31, 2013 4:23 pm

Re: Gallery Problem

Post by delve2013 »

You are a legend, it worked perfectly!

Thank you :)
delve2013
Forum Members
Forum Members
Posts: 91
Joined: Thu Jan 31, 2013 4:23 pm

Re: [SOLVED] Gallery Problem

Post by delve2013 »

If I wanted to change the target page to a full url how would I do that?
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [SOLVED] Gallery Problem

Post 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?
- ...?
Post Reply

Return to “Modules/Add-Ons”