View one image

Discussion in 'Customizations' started by lowis, Oct 3, 2012.

  1. lowis Customer

    I want to expose my issue:

    I have created a float box in my website http://bitly.com/RbS092 I want to set up one image that come from viewlistning.php I dont know how could I limeted one image of 5 http://prntscr.com/gqd9e I think that not look good see five image aside in another side the same images

    This is the code that I have inserted into my float box:
    PHP:
    <div>{* This the image display portion *}
                {if 
    $viewphotos=="Y" && $data <> ''}
                    {foreach 
    from=$data item=image}
                        <
    a href="photos/{$image.image}" title="{$image.title}" class="thickbox" rel="gallery"><img src="thumbs/small_{$image.image}" alt="{$image.title}" /></a><br /><br />
                    {
    foreachelse}
                        <
    img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
                    {/foreach}
                {else}
                    <
    img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
                {/if}
                {* 
    This ends the image display portion *}</div>
            </
    div>
    Thanks in advance!
  2. Mike-N-Tosh Developer & Moderator

    Off of the top of my head, I believe that you are actually looking for {$data.0.image}.
    Try that if it doesn't work, then use the smarty debug to find the available variables in the template.
  3. lowis Customer

    Hi Mike thanks you for your replay, I could see one image but the image is repeated depending on the number of images that I have in the listing: look this http://prntscr.com/gr2qa How could I see one image. I tried to view in the debug but nothing seem to be related with that issue.
  4. Mike-N-Tosh Developer & Moderator

    Most likely because you have it in a "foreach" loop. Get rid of the loop.
  5. lowis Customer

    Hi Mike this is my code that I inserted into layout.tpl I dont see the loop that you said:
    PHP:
    <div>{if $viewphotos=="Y" && $data <> ''}
        {foreach 
    from=$data  item=image}
        <
    a href="photos/{$image.image}" title="{$image.title}" class="thickbox" rel="gallery"><img src="thumbs/small_{$data.0.image}" alt="{$image.title}" /></a><br />
        {
    foreachelse}
        <
    img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
        {/foreach}
        {else}
        <
    img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
        {/if}
        {* 
    This ends the image display portion *}</div>
            </
    div>
    I dont know how do it.
  6. Mike-N-Tosh Developer & Moderator

    Maybe like this?
    Code:
    <div>
        {if $viewphotos=="Y" && $data <> ''}
            <a href="photos/{$image.image}" title="{$image.title}" class="thickbox" rel="gallery">
                <img src="thumbs/small_{$data.0.image}" alt="{$image.title}" />
            </a><br />
        {else}
            <img src="templates/{$smarty.const.MAIN_TEMPLATE}/images/nophoto.gif" width="100" hspace="5" vspace="5" border="1" />
        {/if}
        {* This ends the image display portion *}
    </div>
    
  7. lowis Customer

Share This Page