Can somebody help me figure out, method of creating a new custom function by using “my_changes” addon or just creating a raw file in functions folder.
Vivek
/* Assign function to variable /
{assign var=“my_variable” value=0|fn_my_changes_my_function}
/ Output the variable */
{$my_variable}
Thanks for replying Requin Creative, but my question was regarding the steps on how to create, custom functions in my_changes addon.
I tried to create custom function in “my_changes” addon in “func.php” file (cs-cart ver. 4.0.x) , but when I called that function, it gives me “Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template “/home/beta/cscart/design/themes/basic/templates/blocks/checkout/products_in_cart.tpl” on line 46 “{$vr.variant_id|fn_get_variant_icon}
” unknown modifier “fn_get_variant_icon”' in /home/beta/cscart/app/lib/other/smarty/sysplugins/smarty_internal_templatecompilerbase.php:665 Stack trace: #0 /home/beta/cscart/app/lib/other/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie…', 46) #1 /home/beta/cscart/app/lib/other/smarty/sysplugins/smarty_internal_templatecompilerbase.php(473): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /home/beta/cscart/app/lib/other/smarty/sysplugins/smarty_internal_templatecompilerbase.php(257): Smarty_Internal_TemplateCompilerBase->callTagCompiler('pr in /home/beta/cscart/app/lib/other/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 665” error message.
I tried with “fn_my_changes_get_variant_icon” too, but same error.
Can you please guide me on that ?
Below is code of my “func.php” file.
{php}
use Tygh\Registry;
if (!defined('BOOTSTRAP')) { die('Access denied'); }
function get_variant_icon($variant_id)
{
return $variant_id;
}
{/php}
Vivek
Hi Vivrk,
Please try
#func.php```php
function fn_my_changes_get_variant_icon($variant_id){
return $variant_id;
}
```
#products_in_cart.tpl
```php
{$vr.variant_id|fn_my_changes_get_variant_icon}
```
---
Valentin
[color=#808080][size=2]part of hungryweb.net[/size][/color]
Tried that but I'm getting the same error as mentioned in previous post.
Is there something, I'm missing in function creation process, like registering a function in cs-cart registry ?
I also tried putting a line “use Tygh/Registry” in “func.php” at top but still same error.
Vivek
Didi you clear cache? ?cc&ctpl
Yes did that too, same error still prevails.
I think there is a change in way cs-cart allows to create custom funcs in ver 4.0.x
I tried to refer the uses of “my_changes” addon, but didn't got anything about custom function creation.
you have my_changes addon active?
Thanks man, I just kind of overlooked that setting in admin.
It was disabled, think that's why I was getting “syntax error in template”.
Now I'm gonna use one of mysql functions of cs-cart to get the product-options icon from database.
Thanks again!!
Vivek
Valentin, here is a issue, I'm finding it a bit tricky.
Whenever I turn on the “my_changes” addon from admin, I find that on frontend “Newsletter” checkbox from step 2 has text label disappeared. If I turn addon “disabled” then it appears again.
Vivek
i don't know what you add into the function fn_my_changes_get_variant_icon or if my_changes have some other functionality
Hey Valentin,
Sometime ago, I customized the sidebar price-filter on category view page, from slider to checkbox selector.
But I ain't getting product count for each price filter in the brackets in front of them.
Price filter is ajax in nature.
Can you help me on that ?
Vivek
It's urgent, so please reply immediately.
can you please send me a PM te link to site to see and understand better?
Below is the link to the page, where price filter is.
http://beta.elayers.net/cscart/index.php?dispatch=categories.view&category_id=223
I want to show product count in brackets for “Price” filter just like other filters.
Vivek
I see that price filter is modified in the v2 style (price range), current version (CS-Cart: version 4.0.1 MULTIVENDOR) imported data from an older version or is a clean install?
Please PM me an email adress for a faster contact, is a custom work and i need to see code in order to give you a solution
Guys how I can write a controller for a block template, I don't want to call a modifier function with smarty to get my data from the database, I want to sent my data for the template block as a variable assigned from the controller.
Guys how I can write a controller for a block template, I don't want to call a modifier function with smarty to get my data from the database, I want to sent my data for the template block as a variable assigned from the controller.
For example, you can check how the block with payment images works. The schema is simple:
'payment_methods' => array( 'content' => array( 'items' => array( 'type' => 'function', 'function' => array('fn_get_payment_methods_images'), ), ), 'templates' => 'blocks/payments.tpl', 'wrappers' => 'blocks/wrappers', 'cache' => array( 'update_handlers' => array('payments', 'payment_descriptions'), ), ),
The block works with the array which is returned by the fn_get_payment_methods_images function