Conditionals help
Posted: 09 July 2008 05:35 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  19
Joined  07-05-2008

Hello,

I want to display images inside a div tag. I want to check if there is a image assigned to a weblog field and if not to display a default image.

I’ve written this code but it doesn’t work. If there is a image assigned it displays it but it doesn’t display the default image. The path to the image is correct.

<div id="left_clmn">

  
  
{exp:weblog:entries weblog="{embed:currentweblog}"}

       {if left_image}

           {left_image}

       {if
:elseif left_image == ""}

            
<img src="{site_url}images/interface/synthesi.jpg" alt="">

       
{/if}

  {
/exp:weblog:entries}
    

</div>

Thank you in advance

 Signature 

My personal website

Profile
 
 
Posted: 14 July 2008 05:48 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
RankRankRankRank
Total Posts:  1018
Joined  03-25-2005

try replacing

{if:elseif left_image == ""}
with
{if
:else}

 Signature 

BKDesign Solutions - Learn XHTML and use   Web Standards to build accessible websites that validate

Profile
 
 
Posted: 15 July 2008 03:53 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  19
Joined  07-05-2008

No luck…It doesn’t work

 Signature 

My personal website

Profile
 
 
Posted: 15 July 2008 04:15 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6552
Joined  04-15-2006

If I’m seeing correctly you are saying that the code works if there is an image but not if there isn’t, right?

In that case I’m pretty sure I can see what your problem is wink, hopefully! grin

You have this code here :

<div id="left_clmn">

{exp:weblog:entries weblog="{embed:currentweblog}"}
{if left_image}
{left_image}
{if
:elseif left_image == ""}
<img src="{site_url}images/interface/synthesi.jpg" alt="">
{/if}
{
/exp:weblog:entries}

</div>

What you actually need is this :

<div id="left_clmn">

{exp:weblog:entries weblog="{embed:currentweblog}"}
{if left_image
!= ""}
{left_image}
{if
:else}
<img src="{site_url}images/interface/synthesi.jpg" alt="">
{/if}
{
/exp:weblog:entries}

</div>

Give that a try and see if it works, should do hopefully?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 15 July 2008 04:28 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Avatar
Total Posts:  19
Joined  07-05-2008

Thanks Mark it worked! The !=”” did the trick. I suppose the shorthand way it doesn’t work.

 Signature 

My personal website

Profile
 
 
Posted: 15 July 2008 04:35 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15379
Joined  05-15-2004

Not with advanced conditionals, no.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 15 July 2008 04:39 AM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6552
Joined  04-15-2006
w84me - 15 July 2008 04:28 AM

Thanks Mark it worked! The !=”” did the trick. I suppose the shorthand way it doesn’t work.

As Ingmar said no they won’t work like that in this case. More information on Conditional variables and usage here if you’d like a light read wink.

Glad it worked for you though grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64933 Total Logged-in Users: 55
Total Topics: 81900 Total Anonymous Users: 32
Total Replies: 440264 Total Guests: 249
Total Posts: 522164    
Members ( View Memberlist )
Newest Members:  Kathryn DaviesPetrovichusharurblaisdellLevagstudioigotthelemonmileswkakiharaAurels