Gallery custom fields

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
gionda
Forum Members
Forum Members
Posts: 91
Joined: Mon Aug 17, 2009 11:45 am

Gallery custom fields

Post by gionda »

Hi, I have created a field where, in every gallery, I would like to include links to external sites in _target blank. What code should I put in the template?
thanks
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Gallery custom fields

Post by Jos »

Depends if the field is related to the gallery you are looking at, or related to the images or subgalleries.

For gallery related field:
{$fields.your_field_alias.value}

For image/subgallery related field:
{$image->fields.your_field_alias.value}

http://wiki.cmsms.nl/index.php/Gallery#Custom_Fields
gionda
Forum Members
Forum Members
Posts: 91
Joined: Mon Aug 17, 2009 11:45 am

Re: Gallery custom fields

Post by gionda »

I used the code you've written on another custom field that contains only text, but in the "Link" field I wanted to appear clickable url (<a href ...)
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Gallery custom fields

Post by velden »

gionda wrote:I used the code you've written on another custom field that contains only text, but in the "Link" field I wanted to appear clickable url (<a href ...)
gionda, that should be basic knowledge:

Create the link in your template:

Code: Select all

<a href="{$image->fields.your_field_alias.value}" target="_blank">{$image->fields.your_field_alias.value}</a>
gionda
Forum Members
Forum Members
Posts: 91
Joined: Mon Aug 17, 2009 11:45 am

Re: Gallery custom fields

Post by gionda »

Sorry, you're right, I had already tried but I do not see the url in subgallery.
My template is

Code: Select all

<div class="gallery">
{if !empty($gallerycomment)}<div class="gallerycomment">{$gallerycomment}
<a href="{$fields.link.value}" target="_blank"></a>
</div>{/if}
{* <p>{$imagecount}</p> *}
<div class="pagenavigation">
{if $pages > 1}
<div class="prevpage">{$prevpage}</div>
<div class="nextpage">{$nextpage}</div>
{/if}
{if !$hideparentlink && !empty($parentlink)}<div class="parentlink">{$parentlink}</div>{/if}
{if $pages > 1}<div class="pagelinks">{$pagelinks}</div>{/if}
</div>
{foreach from=$images item=image}
<div class="img">
{if $image->isdir}
<a href="{$image->file}" title="{$image->titlename}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a><br />
{$image->titlename}
{else}
<a class="group" href="{$image->file|escape:'url'|replace:'%2F':'/'}" title="{$image->comment}" rel="prettyPhoto[{$galleryid}]"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a>
{/if}
</div>

<div class="gurl"><a href="{$image->fields.link.value}" target="_blank">{$image->fields.alue}</a></div>

{/foreach}
<div class="galleryclear">&nbsp;</div>
</div>
I have to study smarty :-[
Thanks for your patience
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Gallery custom fields

Post by velden »

first of all: you have a typo
<div class="gurl"><a href="{$image->fields.link.value}" target="_blank">{$image->fields.link.value}</a></div>
Then I assume the custom field is connected to images and not (sub) galleries? Move it inside the {else} {/if} block:

Code: Select all

<div class="gallery">
{if !empty($gallerycomment)}<div class="gallerycomment">{$gallerycomment}
<a href="{$fields.link.value}" target="_blank"></a>
</div>{/if}
{* <p>{$imagecount}</p> *}
<div class="pagenavigation">
{if $pages > 1}
<div class="prevpage">{$prevpage}</div>
<div class="nextpage">{$nextpage}</div>
{/if}
{if !$hideparentlink && !empty($parentlink)}<div class="parentlink">{$parentlink}</div>{/if}
{if $pages > 1}<div class="pagelinks">{$pagelinks}</div>{/if}
</div>
{foreach from=$images item=image}
<div class="img">
{if $image->isdir}
<a href="{$image->file}" title="{$image->titlename}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a><br />
{$image->titlename}
{else}
<a class="group" href="{$image->file|escape:'url'|replace:'%2F':'/'}" title="{$image->comment}" rel="prettyPhoto[{$galleryid}]"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a>
<div class="gurl"><a href="{$image->fields.link.value}" target="_blank">{$image->fields.link.value}</a></div>
{/if}
</div>

{/foreach}
<div class="galleryclear">&nbsp;</div>
</div>
gionda
Forum Members
Forum Members
Posts: 91
Joined: Mon Aug 17, 2009 11:45 am

Re: Gallery custom fields

Post by gionda »

the custom field is connected to the subgallery, not the images. Are galleries of gardens and I wanted to create a tab for each gallery by adding under the "comment" field the geographical location and the link to the site of the garden.
thanks
I forgot, I have a main gallery "public garden" and many sub galleries of gardens, the link appears only in the main gallery "public garden".
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Gallery custom fields

Post by velden »

Try:

Code: Select all

<div class="gallery">
{if !empty($gallerycomment)}<div class="gallerycomment">{$gallerycomment}
<a href="{$fields.link.value}" target="_blank"></a>
</div>{/if}
{* <p>{$imagecount}</p> *}
<div class="pagenavigation">
{if $pages > 1}
<div class="prevpage">{$prevpage}</div>
<div class="nextpage">{$nextpage}</div>
{/if}
{if !$hideparentlink && !empty($parentlink)}<div class="parentlink">{$parentlink}</div>{/if}
{if $pages > 1}<div class="pagelinks">{$pagelinks}</div>{/if}
</div>
{foreach from=$images item=image}
<div class="img">
{if $image->isdir}
<a href="{$image->file}" title="{$image->titlename}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a><br />
{$image->titlename}
{else}
<a class="group" href="{$image->file|escape:'url'|replace:'%2F':'/'}" title="{$image->comment}" rel="prettyPhoto[{$galleryid}]"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a>
<div class="gurl"><a href="{$image->link.value}" target="_blank">{$image->link.value}</a></div>
{/if}
</div>

{/foreach}
<div class="galleryclear">&nbsp;</div>
</div>
Post Reply

Return to “Modules/Add-Ons”