X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Smarty Syntax {elseif} - help needed (https://forum.x-cart.com/showthread.php?t=8110)

Tye 06-15-2004 09:10 PM

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

BCSE 06-16-2004 03:46 AM

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

Tye 06-16-2004 04:43 AM

Hi Carrie

thanks for taking time to reply.

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

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.

shan 06-16-2004 04:55 AM

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

Tye 06-16-2004 05:04 AM

Thanks Shan

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

Cheers

BCSE 06-16-2004 05:19 AM

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

Tye 06-16-2004 07:49 PM

I love you, I love you all :D

Thanks Carrie and Shan.

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

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


All times are GMT -8. The time now is 07:54 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.