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

if no. of subcategories greater than X, do this

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-10-2008, 01:10 AM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

Default 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
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #2  
Old 02-10-2008, 08:42 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

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

Where is the content to be displayed?
__________________
xcart 5.1.2
Reply With Quote
  #3  
Old 02-10-2008, 10:00 AM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

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

it's to be used on subcategories.tpl
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #4  
Old 02-10-2008, 11:08 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

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

{if $categories and $subcategories <= 3}
content
{else}
content
{/if}

will that work?
__________________
xcart 5.1.2
Reply With Quote
  #5  
Old 02-10-2008, 11:13 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default 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}
Reply With Quote
  #6  
Old 02-10-2008, 12:35 PM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

Default 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.
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #7  
Old 02-10-2008, 02:01 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

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

Can someone explain the difference please? thx
__________________
xcart 5.1.2
Reply With Quote
  #8  
Old 02-10-2008, 02:24 PM
  kube's Avatar 
kube kube is offline
 

X-Adept
  
Join Date: Sep 2005
Location: London: a small place East of Wales
Posts: 529
 

Default 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
__________________
Doms
kube v4.1.9
Reply With Quote
  #9  
Old 02-10-2008, 02:31 PM
  kube's Avatar 
kube kube is offline
 

X-Adept
  
Join Date: Sep 2005
Location: London: a small place East of Wales
Posts: 529
 

Default 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.
__________________
Doms
kube v4.1.9
Reply With Quote
  #10  
Old 02-10-2008, 02:34 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

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

What does the | do?
__________________
xcart 5.1.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 10:58 AM.

   

 
X-Cart forums © 2001-2020