Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

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

 
  • yinyuantao
  • Newbie
  • Members
  • Join Date: 26-Jul 13
  • 9 posts

Posted 31 July 2013 - 02:07 AM #1

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

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 31 July 2013 - 09:20 AM #2

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.
Hire StellarBytes for CS-Cart Design & Development Services

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1275 posts

Posted 31 July 2013 - 10:30 AM #3

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.


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 /skins/basic/customer/common_templates/price.tpl
1. replace
{strip}
with
{strip}{hook name="common:price"}

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

after this modification you can hook by adding /skins/basic/customer/addons/addon_name/hooks/common/price.override.tpl

* in case of update you may need to modify again /skins/basic/customer/common_templates/price.tpl


I hope that helps,

---
Valentin
part of hungryweb.net

 
  • yinyuantao
  • Newbie
  • Members
  • Join Date: 26-Jul 13
  • 9 posts

Posted 31 July 2013 - 02:40 PM #4

* in case of update you may need to modify again /skins/basic/customer/common_templates/price.tpl


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

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12071 posts

Posted 01 August 2013 - 07:42 AM #5

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.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.