Jump to content

Do not show image when there is no link inserted.


werushka

Recommended Posts

In my .tpl file there is a code as it posted below

<img src="{$link_field1}" height="100px" alt="Resim Yok" style="float:left; padding-right:10px;padding-top:0px;"/>

 

What this does is that when the user inserts a image url when making a post then the image is showed on the page, but if the user does not enter a image url then the image location has "X" no image icon.

 

I would like to need help with the coding that when there is No image url submitted then the image location should be empty instead of "x"

 

I should write a code smilar to this

 

{if $link_field1 eq notnull}

<img src="{$link_field1}" height="100px" alt="Resim Yok" style="float:left; padding-right:10px;padding-top:0px;"/>

{else}

leave it empty

{/if}

 

 

Thanks for your replies it is not a script it is just Pligg CMS.

 

In the mean time the syntax gives error (noting shows on the page)

 

Example of how php is used in template file is as follows this is just an example

 

{if $use_title_as_link eq true}

{if $url_short neq "http://" && $url_short neq "://"}

<a href="{$url}" {if $open_in_new_window eq true} target="_blank"{/if}>{$title_short}</a>

{else}

<a href="{$story_url}">{$title_short}</a>

{/if}

did you not just answer your own question?

 

if (!$link_field1){
        echo'<img src="'.$link_field1.'" height="100px" alt="Resim Yok" style="float:left; padding-right:10px;padding-top:0px;"/>';
      }

 

I meant this sorry

if ($link_field1 !=''){
        echo'<img src="'.$link_field1.'" height="100px" alt="Resim Yok" style="float:left; padding-right:10px;padding-top:0px;"/>';
      }

Thanks for your reply actually i did this and worked

 

{if $link_field1}

        <img src="{$link_field1}" height="100px" alt="Resim Yok" style="float:left; padding-right:10px;padding-top:0px;"/>

      {else}

      {/if}

 

Thank you very much for your help :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.