|
|
|
|
|
Tool Kit Demo
|
| |
|
|
Quantity in Basket:
None
Code: TOOLKITDEMO
Shipping Weight: 1.00 pounds
Price: $2.00
Cost: $3.00
| Group Discount |
| 10 |
1.00%
($1.98)
|
| 6 |
0.50%
($1.99)
|
1 available for immediate delivery
|
| |
|
This page demonstrates the use of the tool kit function library to create new variables
and make changes to existing variables. The %product_name% can easily replace a token
within a description field. #Alternate Description: Can have other text here, e.g. greeting
|
|
|
| |
Not yet rated
|
Tool Kit Functions Test:
1. Use the substring to show the first x characters in a string. In this example,
<mvt:item name="toolkit" param="substring|l.all_settings:product:descrip,1,20" />,
we display the first 20 characters in the product description.
This page demonstrat
2. Use the gettoken to separate a string using a delimiter character. In this example,
<mvt:item name="toolkit" param="gettoken|l.all_settings:product:descrip,#,2" />
we display the text after the # in the product description.
Alternate Description: Can have other text here, e.g. greeting
A variation of this is the vgettoken which allows use of a variable in the last parameter
instead of a constant. So you could change the 2 above to a variable.
3. Use the vassign to create and name a global variable from a variable. In this example,
<mvt:item name="toolkit" param="vassign|product_name|l.all_settings:product:name" />
creates a variable named product_name from the dynamic variable l.all_settings:product:name. Then you can use the mvt to evaluate the global:product_name variable.
Tool Kit Demo
4. Use the sassign to create and name a global variable from a string. In this example,
<mvt:item name="toolkit" param="sassign|greeting|Happy Mother\'s Day" />
creates a variable named greeting from the string "Happy Mother's Day". Note the use of the backslash to escape the apostrophe character. Then you can use the mvt to evaluate the global:greeting variable.
Happy Mother's Day
5. Use the vlength to create and name a global variable which is the length (number of characters) of another variable. In this example,
<mvt:item name="toolkit" param="vlength|name_length|l.all_settings:product:name" />
creates a variable named name_length from the length of the dynamic variable l.all_settings:product:name. Then you can use the mvt to evaluate the global:name_length variable or you can use it in other functions.
13
6. Use the vglosub to replace a string with a dynamic variable inside of another variable. For example, in the product description you can replace the %product_name% with a variable.
<mvt:item name="toolkit" param="vglosub|l.all_settings:product:descrip,%product_name%,l.all_settings:product:name" />
In this example it replaces it with the l.all_settings variable.
This page demonstrates the use of the tool kit function library to create new variables
and make changes to existing variables. The Tool Kit Demo can easily replace a token
within a description field. #Alternate Description: Can have other text here, e.g. greeting
7. You can use the same vglosub to replace a string with a variable that you create with the assign commands above in the page template. As example,
<mvt:item name="toolkit" param="vglosub|l.all_settings:product:descrip,greeting,g.greeting" />
use the g.greeting variable as the replacement.
This page demonstrates the use of the tool kit function library to create new variables
and make changes to existing variables. The Tool Kit Demo can easily replace a token
within a description field. #Alternate Description: Can have other text here, e.g. Happy Mother's Day
8. Use the sglosub to replace a string with another string. For example,
<mvt:item name="toolkit" param="sglosub|l.all_settings:product:descrip,function,features" />
replace the word function with the word features in the product description.
This page demonstrates the use of the tool kit features library to create new variables
and make changes to existing variables. The Tool Kit Demo can easily replace a token
within a description field. #Alternate Description: Can have other text here, e.g. Happy Mother's Day
9. Use the math_add to calculate the sum of two variables to a new number. For example,
<mvt:item name="toolkit" param="math_add|sum|l.all_settings:product:price|l.all_settings:product:cost" />
sum the price plus the cost to get a variable called sum.
5
10. Use the math_subtract to calculate the difference between two variables to a new number. For example,
<mvt:item name="toolkit" param="math_subtract|difference|l.all_settings:product:cost|l.all_settings:product:price" />
subtract the cost minus the price to get a variable called difference.
1
11. Use the math_multiply to save the result of variable1 times variable2 to a new number. For example,
<mvt:item name="toolkit" param="math_multiply|times|l.all_settings:product:cost|l.all_settings:product:price" />
multiply the cost times the price to get a variable called times.
6
12. Use the math_divide to save the result of variable1 divided by variable2 to a new number. For example,
<mvt:item name="toolkit" param="math_divide|result|l.all_settings:product:cost|l.all_settings:product:price" />
multiply the cost times the price to get a variable called times.
1.5
13. Use the currencyformat to format a variable to a text string formatted to the store's currency. For example,
<mvt:item name="toolkit" param="currencyformat|formatted_savings|difference" />
Format the difference between the cost and price to show savings.
Savings: $1.00
14. Use the a combination of functions to show percent savings of one price off another. The mathematical operation needs to be broken down into multiple steps. For example,
<mvt:item name="toolkit" param="math_subtract|difference|l.all_settings:product:cost|l.all_settings:product:price" />
<mvt:item name="toolkit" param="math_divide|result|difference|l.all_settings:product:cost" />
<mvt:item name="toolkit" param="sassign|value2|100" />
<mvt:item name="toolkit" param="math_multiply|times|result|value2" />
<mvt:item name="toolkit" param="math_round|times|times|2" />
obtains the difference between the cost and price. Then divides the difference by the cost. Then
multiplies that division result times 100. And finally math_round will round that result to 2 decimal places.
Savings: 33.33%
15. Time/date functions: These functions were used to display the current time and date
of our server (offset -4).
<mvt:item name="toolkit" param="set_time_zone|our_time|-4" />
<mvt:item name="toolkit" param="time_t_year|nyear|our_time" />
<mvt:item name="toolkit" param="time_t_month|nmonth|our_time" />
<mvt:item name="toolkit" param="time_t_dayofmonth|ndayofmonth|our_time" />
<mvt:item name="toolkit" param="sassign|months|Jan#Feb#Mar#Apr#May#Jun#Jul#Aug#Sep#Oct#Nov#Dec" />
<mvt:item name="toolkit" param="vgettoken|months,#,nmonth" /> <mvt:item name="toolkit" param="time_t_hour|nhour|our_time" />
<mvt:item name="toolkit" param="padl|chour|nhour|2|0" />
<mvt:item name="toolkit" param="time_t_minute|nminute|our_time" />
<mvt:item name="toolkit" param="padl|cminute|nminute|2|0" />
<mvt:item name="toolkit" param="time_t_second|nsecond|our_time" />
<mvt:item name="toolkit" param="padl|csecond|nsecond|2|0" />
<mvt:item name="toolkit" param="time_t_dayofweek|ndayofweek|our_time" />
<mvt:item name="toolkit" param="sassign|days|Sunday#Monday#Tuesday#Wednesday#Thursday#Friday#Saturday" />
<mvt:item name="toolkit" param="vgettoken|days,#,ndayofweek" />
Our time zone: -4
Current year (our time): 2008
Current month (our time): 11
Current day (our time): 21
Current date (our time): 11
/
21
/
2008
Current date (our time): Nov
21,
2008
Current hour (our time): 11
(left padded: 11)
Current minute (our time): 2
(left padded: 02)
Current second (our time): 47
(left padded: 47)
Current time (our time): 11:02:47
Current day of week (our time): 6
Friday
16. Use the callurl to pass fields, (eg hour, minute, second) to a remote program (mvc, php, etc) and return result (eg the value of the 3 multiplied together in a web page). The return result can be displayed with the mvt or it can just be ignored, depending on your need for the function. For example it could display the contents of the file at that location or it could do something like sign the customer up for a mailing list. For example,
<mvt:item name="toolkit" param="callurl|sample|http://www.emporiumplus.com/public/calltest.mvc|POST|nhour,nminute,nsecond" />
You could use the mvt of the variable to display the return result, in this case "sample".
<html>
<body>
Test Result:
1034
</body>
</html>
Order this module
|