| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Smarty Math using a Variable | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Smarty Math using a Variable
I am trying to customize the layout for the way the subcategories.tpl template displays subcategories and have run into a problem using a variable in a math equation. The variable is the "count" of the number of subcategories and it can easily be made to correctly show the correct number on the page (just to know it does carry the correct number) with:
Code:
I am trying to use that variable in a math formula to divide 100 by the variable and yield the correct percentage value for table cells based upon how many subcategories there are (never more than 5 in this store, which would be 20%). The following yields the desired end product using a fixed value, "x=2" in this case, in place of the variable. Code:
All of my attempts to get the variable working in place of the fixed value result in Smarty errors so I am obviously missing the correct syntax to be using. Any ideas? XCart 4.0.17 Regards, John
__________________
John Harwood v3.5.14, v4.0.17, v4.1.8 |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Smarty Math using a Variable
Have you tried to use this, which is the number of elements in the array:
x=$subcategories|@count You can try and print it first, like you were doing before to see if it has the right value: <p>count: {$subcategories|@count}</p>
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#3
|
|||||||
|
|||||||
Re: Smarty Math using a Variable
Looks like that's the ticket! I know I had tried some variations with the pipe character but must have done it wrong (obviously).
Many Thanks! John
__________________
John Harwood v3.5.14, v4.0.17, v4.1.8 |
|||||||
|
|||
X-Cart forums © 2001-2020
|