Hide image thumbs if only 1 image

Discussion in 'Customizations' started by freeze2, May 24, 2013.

  1. freeze2 Super Moderator

    Currently I am showing the full size image {$data.0.image} on the viewlisting.tpl with the image thumbs underneath.

    To call the thumbs I use the following:

    Code:
    {if $viewphotos=="Y" && $data <> ''}
    <div id="listingimages">     
      <ul class="gallery">
        {foreach from=$data item=image}
        <li><a href="photos/{$image.image}" title="{$image.title}" class="thickbox" rel="gallery"><img src="thumbs/small_{$image.image}" alt="{$image.title}" /></a></li>
        {/foreach}
      </ul>
    </div>
    {/if}
    Because I use the full size image on the listing, my thought was that it would be nice then to hide the thumbs if there is 1 or less images uploaded.

    Using the {debug} I found the following:

    {$data}

    Array (6)

    0 => Array (7)
    id => "15"
    pid => "3"
    title => "Image Title"
    image => "dsc02908.jpg"
    rank => "1"
    width => 600
    height => 450

    (repeats for all 6 images)

    Thinking it through, I tried wrapping a few variations of the following around the thumbs hoping to get it to work.

    Code:
    {if $data.Array <= 1}
    {else}
    ## Show Gallery ##
    {/if}
    This didn't work and my obvious lack of programming skills is showing clearly

    Any direction would be great....thanks!
  2. Mike-N-Tosh Owner

    I haven't tried or tested this, but try something like this: {if count($data) < 2}

    Smarty should be "smart" enough to know that $data is an array, so just count the array.

    Hope that helps!
    Mike
  3. freeze2 Super Moderator

    Thanks Mike...that did it !

    I am completely blown away at how versatile this script is...just love it!

Share This Page