[SOLVED] Gallery: $gallerycomment vs $image->comment

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

[SOLVED] Gallery: $gallerycomment vs $image->comment

Post by wmdvanzyl »

I have a situation where i am trying to access the $gallerycomment of the current (in this case second) $image (which definitely returns true on $image->isdir).

Using $gallerycomment gives the comment of the first gallery in the array of $images. There must be something wrong with the logic in my loop?

Code: Select all

...
{foreach from=$images item=image}
        ...
	{if $image->isdir}
		<a href=... ><img src=... /></a><br />
		{$image->titlename}&nbsp;...<div ...>...{$gallerycomment}...</div>
        ...
Here is the full template:

Code: Select all

<div class="pure-u-1-1">
{foreach from=$images item=image}
	<div class="img">
	{if $image->isdir}
		<a href="{$image->file}" title="{$image->file}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename }" /></a><br />
		{$image->titlename}&nbsp;<a href="#{$image->titlename}" rel="prettyPhoto"><img src="uploads/images/details.jpg" title="Details" alt="Click for details" height="15px" /></a><div id="{$image->titlename}" class="hidden">{$gallerycomment}</div>
	{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>
{/foreach}
</div>
<div class="galleryclear">&nbsp;</div>
</div>
Last edited by wmdvanzyl on Sun Aug 10, 2014 8:30 pm, edited 2 times in total.
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Gallery: Accessing the $gallerycomment of the current $i

Post by Jos »

Have you tried <pre>{$images|print_r}</pre> ?
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Re: Gallery: Accessing the $gallerycomment of the current $i

Post by wmdvanzyl »

Right now, i'm getting no comments at all to show... so i am going backwards :p
Jos wrote:Have you tried <pre>{$images|print_r}</pre> ?

Code: Select all

Array
(
    [0] => stdClass Object
        (
            [fileid] => 21
            [file] => http://renaultpaarl.modh.co.za/gallery/used_vehicles/Clio-2010/15
            [filedate] => 2014-08-04 11:38:02
            [filename] => Clio-2010
            [title] => Clio 2010
            [titlename] => Clio 2010
            [comment] => Renault Clio 2010 perfect condition
            [fileorder] => 0
            [active] => 1
            [isdir] => 1
            [galleryid] => 2
            [gallery_url] => http://renaultpaarl.modh.co.za/gallery/used_vehicles/15
            [thumb] => uploads/images/GalleryThumbs/25-6.jpg
            [fields] => Array
                (
                )

        )

    [1] => stdClass Object
        (
            [fileid] => 26
            [file] => http://renaultpaarl.modh.co.za/gallery/used_vehicles/Twingo-2011/15
            [filedate] => 2014-08-04 11:48:45
            [filename] => Twingo-2011
            [title] => Twingo 2011
            [titlename] => Twingo 2011
            [comment] => test
            [fileorder] => 0
            [active] => 1
            [isdir] => 1
            [galleryid] => 2
            [gallery_url] => http://renaultpaarl.modh.co.za/gallery/used_vehicles/15
            [thumb] => uploads/images/GalleryThumbs/35-6.jpg
            [fields] => Array
                (
                )

        )

)
1
But replacing {$gallerycomment} with {$image->comment} still gives me blank results.

Logically, I am looking to achieve $image->gallerycomment

EDIT: It would seem the issue is not at all related to the core Gallery module, but rather to prettyPhoto.

Using

Code: Select all

{$image->comment} instead of {gallerycomment}
is definitely correct.

Replacing:

Code: Select all

 {$image->titlename}&nbsp;...</div>
with:

Code: Select all

 {$image->comment}&nbsp;...</div>
gave correct result. It only gets lost inside the prettyPhoto popup.


GOT IT!

1.) Every div that i want to display with prettyPhoto needs to have a unique ID - that's why i was getting wrong comment.
2.) The ID of the div cannot have spaces in it so use smarty replace command to replace spaces with udnerscores.
3.) Use $image->comment. If the $image is a directory, then it is the same as calling $gallerycomment when looking at $images inside that gallery.

Template code:

Code: Select all

<div class="gallery pure-g-r">
<div class="pagenavigation pure-u-1-1 galleryclear">
{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 $gallerytitle ne "Pre-Owned Vehicles"}<pre id="gallerycomment">{$gallerycomment}</pre>{/if}
{if $pages > 1}<div class="pagelinks">{$pagelinks}</div>{/if}
</div>
<pre style="letter-spacing: normal; display: none">{$images|print_r}</pre>
<div class="pure-u-1-1">
{foreach from=$images item=image}
	<div class="img">
	{if $image->isdir}
		<a href="{$image->file}" title="{$image->file}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename }" /></a><br />
		{$image->titlename}&nbsp;<a href="#{$image->titlename|replace:' ':'_'}" rel="prettyPhoto"><img src="uploads/images/details.jpg" alt="Details" title="Click for details" height="15px" /></a><div id="{$image->titlename|replace:' ':'_'}" class="hidden">{$image->comment}</div>
	{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>
{/foreach}
</div>
<div class="galleryclear">&nbsp;</div>
</div>


Post Reply

Return to “Modules/Add-Ons”