Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Smarty Syntax {elseif} - help needed

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-15-2004, 09:10 PM
 
Tye Tye is offline
 

eXpert
  
Join Date: Nov 2002
Location: Australia
Posts: 284
 

Default Smarty Syntax {elseif} - help needed

Hi guys

Hows it going?

I am having some problems getting some smarty syntax to work and was wondering if anyone has used something similar.

Here is what I have

Code:
{if $cat eq "1"} CONTENT 'A' {elseif $productid eq "11"} CONTENT 'B' {else} CONTENT 'C'

When I use this code - CONTENT 'A' and 'C' work fine - but content 'B' is ignored.

I pulled this of the smarty template site and the only difference I can see is that they use the $name throughout whereas I use $cat and $productid. If this is the problem, has anyone got any ideas on how to get around this?

Code:
{if $name eq "Fred"} Welcome Sir. {elseif $name eq "Wilma"} Welcome Ma'am. {else} Welcome, whatever you are. {/if}

Cheers

Tye
__________________
Today is a beautiful day, grab it while you can and live it to the full

Version 4.2.3 UNIX
Reply With Quote
  #2  
Old 06-16-2004, 03:46 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,060
 

Default

Where's your
{/if}
in your code?

Also, have you tried printing out $productid to see that a value exists for it? I find doing a simple variable print out in smarty and/or php can sometimes be the quickest way to debug something that's not working as you expect it to.

HTH!

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #3  
Old 06-16-2004, 04:43 AM
 
Tye Tye is offline
 

eXpert
  
Join Date: Nov 2002
Location: Australia
Posts: 284
 

Default

Hi Carrie

thanks for taking time to reply.

My {/if} is there - I just forgot to post it

My product is also there, I think... I am not sure what you mean when you say Print the variable... is that like

Code:
<? echo '$productid'; ?>

This product is displaying in the store if this helps.
__________________
Today is a beautiful day, grab it while you can and live it to the full

Version 4.2.3 UNIX
Reply With Quote
  #4  
Old 06-16-2004, 04:55 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Quote:
Originally Posted by Tye

<? echo '$productid'; ?>

thats php not smarty

to show a variable use

{$productid} etc

also make sure that {$productid} is a valid variable first
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #5  
Old 06-16-2004, 05:04 AM
 
Tye Tye is offline
 

eXpert
  
Join Date: Nov 2002
Location: Australia
Posts: 284
 

Default

Thanks Shan

Its late here, I'm tired - I'll have another look tomorrow.

Cheers
__________________
Today is a beautiful day, grab it while you can and live it to the full

Version 4.2.3 UNIX
Reply With Quote
  #6  
Old 06-16-2004, 05:19 AM
  BCSE's Avatar 
BCSE BCSE is offline
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,060
 

Default

I'm guessing it may be more like
{$product.productid} to print the variable out (and to use it) unless you've changed something in the php code assuming you're doing this in skin1/customer/main/product.tpl

So if {$productid} doesn't print anything to the screen, then try {$product.productid}

If that doesn't work, let us know what tpl this code is for and maybe that will help.

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #7  
Old 06-16-2004, 07:49 PM
 
Tye Tye is offline
 

eXpert
  
Join Date: Nov 2002
Location: Australia
Posts: 284
 

Default

I love you, I love you all

Thanks Carrie and Shan.

It was late last night and I was getting mixed up with smarty and php

My correct code should have been

Code:
{if $cat eq "1"} CONTENT 'A' {elseif $product.productid eq "11"} CONTENT 'B' {else} CONTENT 'C' {/if}

Thanks again

Tye
__________________
Today is a beautiful day, grab it while you can and live it to the full

Version 4.2.3 UNIX
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:08 AM.

   

 
X-Cart forums © 2001-2020