cs-cart 3.0.x create addon to override the common template

Hi,



I'm trying to create an add-on which take function return value and put it on the front end .tpl file. That is a common template locate in /skins/basic/customer/common_templates/price.tpl



I create add-on file \var\skins_repository\basic\customer\addons\addon_name\common_templates\price.override.tpl to try replace the original price.tpl file but it doesn't work.



So what can I do to replace the common template or core template with my own code in the cs-cart by add-on? Is that mandatory to use hooker in add-on?



Thank you for your help.





David

If you are placing the addon file in /var/skins_repository/basic/customer/addons/addon_name/ they should be copied to /skins/basic/customer/addons/addon_name/ when you install the addon. Otherwise place the file in the 'skins' directory. The 'skins_repository' is exactly that - a repository for skin files.

[quote]I create add-on file \var\skins_repository\basic\customer\addons\addon_name\common_templates\price.override.tpl to try replace the original price.tpl file but it doesn't work.[/quote]



Only on hooks can be used actions pre, post and override



You need to add hook to price.tpl file and after that you can hook



For this you need to modify [color=#ff0000]/skins/basic/customer/common_templates/price.tpl[/color]

  1. replace
    {strip}
    with
    {strip}{hook name="common:price"}



  2. replace
    {/strip}
    with
    {/hook}{/strip}




    after this modification you can hook by adding [color=#ff0000]/skins/basic/customer/addons/addon_name/hooks/common/price.override.tpl[/color]


  • in case of update you may need to modify again [color=#ff0000]/skins/basic/customer/common_templates/price.tpl[/color]





    I hope that helps,





    Valentin

    [color=#808080][size=2]part of hungryweb.net[/size][/color]

[quote name='Vali' timestamp='1375266603' post='166095']


  • in case of update you may need to modify again [color=#ff0000]/skins/basic/customer/common_templates/price.tpl[/color]



    [/quote]



    Thanks Vali, this is surely helpful.



    But if it need modify again after upgrade, does it seem to be meaningless to have add-on here? Can we avoid change after upgrading?







    David

Depending on what you are wanting to modify, a php hook might be more appropriate. Ie. 'get_product_data' hook in core/fn.catalog.php for V2/3 and app/functions/fn.catalog.php for V4. This will then survive future upgrades until cs-cart decides to rename the hook or change its parameters which they seem to do from time to time without any kind of notification.