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}

 

 

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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;"/>';
      }

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.