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)
-   -   if no. of subcategories greater than X, do this (https://forum.x-cart.com/showthread.php?t=37471)

donavichi 02-10-2008 01:10 AM

if no. of subcategories greater than X, do this
 
Hi,

What I'm trying to do is create an edit that tells x-cart to show 'content A' if there's less than 3 subcategories within a category and 'content B' if there are more than 3...

i realise it's an if statement of some-sort but can't seem to get the syntac right to make x-cart understand what I need it to do.

Any ideas greatly appreciated

ARW VISIONS 02-10-2008 08:42 AM

Re: if no. of subcategories greater than X, do this
 
Where is the content to be displayed?

donavichi 02-10-2008 10:00 AM

Re: if no. of subcategories greater than X, do this
 
it's to be used on subcategories.tpl

ARW VISIONS 02-10-2008 11:08 AM

Re: if no. of subcategories greater than X, do this
 
{if $categories and $subcategories <= 3}
content
{else}
content
{/if}

will that work?

Jon 02-10-2008 11:13 AM

Re: if no. of subcategories greater than X, do this
 
Off hand without looking at the code, I believe it would be:

Code:

{if $subcategories|@count gt 3}
There's more than three.
{else}
There's less than three.
{/if}


donavichi 02-10-2008 12:35 PM

Re: if no. of subcategories greater than X, do this
 
Thanks Ashley but that didn't do it - Jon's version did though. Thank you both.

ARW VISIONS 02-10-2008 02:01 PM

Re: if no. of subcategories greater than X, do this
 
Can someone explain the difference please? thx :)

kube 02-10-2008 02:24 PM

Re: if no. of subcategories greater than X, do this
 
Quote:

Originally Posted by Ashley
Can someone explain the difference please? thx :)


@count counts the items in the array first, whereas the other method is a bit of a mismatch as the array has named values.

I'm rubbish at explaining things ;D

kube 02-10-2008 02:31 PM

Re: if no. of subcategories greater than X, do this
 
A better understanding would be to print {$subcategories} and it will give you an array, NaN. Whereas, @count gives a number from counting the array to compare with.

ARW VISIONS 02-10-2008 02:34 PM

Re: if no. of subcategories greater than X, do this
 
What does the | do?


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

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