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
Gallery custom fields
Re: Gallery custom fields
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
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
Re: Gallery custom fields
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 ...)
Re: Gallery custom fields
gionda, that should be basic knowledge: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 ...)
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>Re: Gallery custom fields
Sorry, you're right, I had already tried but I do not see the url in subgallery.
My template is
I have to study smarty
Thanks for your patience
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"> </div>
</div>Thanks for your patience
Re: Gallery custom fields
first of all: you have a typo
Then I assume the custom field is connected to images and not (sub) galleries? Move it inside the {else} {/if} block:<div class="gurl"><a href="{$image->fields.link.value}" target="_blank">{$image->fields.link.value}</a></div>
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"> </div>
</div>Re: Gallery custom fields
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".
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".
Re: Gallery custom fields
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"> </div>
</div>



