Can someone explain me the "My changes" addon?

Hello,



how it works the “My changes” Addon? I would like to change Template things and i wouldn´t that after updates are my changes overwrite.



Thanks



best regards!

Unfortunately, I do not think anyone knows for sure because there is little documentation. It probably works the same as the Local Configuration add-on described here:

[url]http://forum.cs-cart.com/showthread.php?t=11656[/url]



However, it may not support local stylesheets. Hopefully, more information will be available soon.



Bob

mhh O.K. thanks, but who can tell me how it work´s this addon?

From the CS-Cart Knowledge Base:



The My changes addon is intended for modifying the default CS-Cart functionality without changing its core. Using this addon for custom changes prevents problems with upgrading a store to the later versions.



My interpretation of this addon is that it works in the background and there is no user functionality.

I wish someone from CS-Cart would explain to us exactly how to use & take advantage of this feature…I cant even tell if it is operational yet. :confused:

Basically, it is meant for template modifications using the hooks found within the tpl files.



Since the my_changes addon is enabled by default in the Addons adminstration, so whatever modifications you placed within the addons/my_changes folder in the skins directory will be executed.



A simple example:

I wish to change the bottom footer html code completely.

Replacing the default text:

Copyright © 2005-2009 CS-Cart.com. Powered by CS-Cart - Shopping Cart Software



with my own HTML code.

Inside bottom.tpl, I will see that there is a hook I can use for this modification:

```php {hook name=“index:bottom”}

{$lang.copyright} © {if $smarty.const.TIME|date_format:"%Y" != $settings.Company.company_start_year}{$settings.Company.company_start_year}-{/if}{$smarty.const.TIME|date_format:"%Y"} {$settings.Company.company_name}. {$lang.powered_by} {$lang.copyright_shopping_cart}


{/hook} ```
The hook name found in the above code, "index:bottom", define the structure which you must use within the /customer/addons/my_changes folder.
So I create a folder name "index", and inside the "index" folder, I will create a file name "bottom.override.tpl"

Inside "bottom.override.tpl", I will paste my own custom HTML code for my own bottom footer. Example: "This is my footer. Copyrighted!""

After saving this "bottom.override.tpl" file, and refreshing your site, you can see that the bottom footer code have been updated to your own custom HTML code.

So the final structure/path will be something like
/customer/addons/my_changes/index/bottom.override.tpl

And the benefit of such is that your changes are kept to a separate file. And so if cscart updates and overwrite the bottom.tpl file, your code are not overwritten at all.
Also always keep an update copy of the contents within the my_changes folder inside the vars/skin_repository/base/customer/addons/my_changes directory, so if you change a new skin, your changes will still be copied over to the new skin directory and be executed.

For more detailed information, you can refer to tbirnseth's thread: [url]http://forum.cs-cart.com/showthread.php?t=11656[/url]
His pdf documentation is very useful, and he includes the hooks that can be used, with instructions on how to use it. His "local changes" addon is created before cscart came out with the "my_changes" addon. In essence, the "my_changes" addon is the similar as his "local_changes" addon, so you do not have to create a new addon, and just use the "my_changes" addon will do for simple changes.

To explain further, I will try to provide another common example :



For example, you want to add your own stylesheet to the site.

Instead of directly modifying the code within the tpl files provided by cscart, you can do the following:



Found within customer\common_templates is the styles.tpl, which defines the stylesheets used by cscart.

You can see within the styles.tpl, they’ve provided a hook for you to use, where the hook name is

{hook name="index:styles"}



So within the customer/addons/my_changes folder, create an “index” folder (if you have not done so already).

Then create a new tpl file to link to your stylesheet.

As you do not want to overwrite cscart’s stylesheets but to add your own stylesheet. You create a new tpl file named “styles.post.tpl”



So the final structure/path will be something like:

customer/addons/my_changes/index/styles.post.tpl



Inside styles.post.tpl, you add the HTML code to link to your stylesheet.

Example for me, I decided to put my own stylesheet inside the my_changes folder too for convenience sake, so I create a folder named “css” and add a new css file named “styles.css” inside there. And then inside styles.post.tpl, I write the HTML code as such:






After doing these, I do a refresh of my web site, and the HTML code will be appended after the css links code of cscart.



Note: the my_changes addon must be set to “Active” in the admin addons area.



Of course you can place your stylesheet anywhere, and then provide a absolute link to link to your css files like:


Thank you very much Nodame for spending your time to clarify all of this!! :wink:

Thanks for clarifying that, nodame. It appears the “My changes” add-on provides the same functionality as tbirnseth’s “Local configuration” add-on with one exception - The “Local Configuration” add-on also allows controller-specific CSS. The good news is that anyone who created a hook using the “Local configuration” add-on can just copy it into place in order to use the developer-supported “My changes” add-on.



I hope that the developers will expand the conflict resolution in the upgrade to check to see if a hooked file exists when code is updated within a hook. They don’t need to (and really cannot) attempt resolution but they can let us know that we need to review our hooked files.



Bob

[quote]

developer-supported

[/quote]



Falling out of my chair laughing…



When have you ever seen a cs-cart developer discuss (or document) any of the internals about how something is intended to work? Hope you’re not holding your breath! :slight_smile:

[quote name=‘tbirnseth’]Falling out of my chair laughing…



When have you ever seen a cs-cart developer discuss (or document) any of the internals about how something is intended to work? Hope you’re not holding your breath! :-)[/QUOTE]

Nope. I am using your Local Configuration add-on. But I do hope they provide some real documentation and some way to highlight potential conflicts in hooked files.



Bob

[quote name=‘jobosales’]Thanks for clarifying that, nodame. It appears the “My changes” add-on provides the same functionality as tbirnseth’s “Local configuration” add-on with one exception - The “Local Configuration” add-on also allows controller-specific CSS. The good news is that anyone who created a hook using the “Local configuration” add-on can just copy it into place in order to use the developer-supported “My changes” add-on.



I hope that the developers will expand the conflict resolution in the upgrade to check to see if a hooked file exists when code is updated within a hook. They don’t need to (and really cannot) attempt resolution but they can let us know that we need to review our hooked files.



Bob[/QUOTE]



Hi Bob,

Yeap, as I said, the “my_changes” addon is similarly to the “local_changes” addon and more for “simple changes” or people who do not have much understanding of how smarty works or indepth HTML knowledge. I did not install the tbirnseth’s addon so I am not completely sure of all the features it supports. But from the thread, tbirnseth’s “Local configuration” addon seems to provide more/better out-of-the-box support. And tbirnseth’s himself does provide better support, and you get faster replies to your queries from him rather than from cscart themselves.

You can always use tbirnseth’s addon since it is very well documented.



For me, as my changes are sometimes quite complex, e.g. adding a custom jready hook to place all my custom jquery document ready code at the bottom of the document (recommended for fasting loading of pages rather than littering various snippets of code everywhere around the HTML source and calling jQuery(document).ready function only once), so sticking them all at one location in my_changes is more convenient for me.



For css, I prefer to have it all in one external file for tracking/maintenance reasons, regardless of controller, since the css file will be cached and do not need reloading when customers navigate around the site. This is of course unless the solution provides dynamically generated compressed minimized cachable combined-into-one-file css files, which I seriously doubt will be anywhere near the top of cscart’s to-do list (provided it’s even on that list.)

I posted this in another forum post earlier, but I felt I should repeat it here:



Hooks are not everything they are made out to be and actually can be very dangerous when upgrading. In many places you will not be using the latest functionality or features if you used a hook. For example from 2.06 to 2.07 a lot of new functionality was added to the cart. The new code is within some very popular hooks. If you used hooks to overwrite or make changes to these areas you will not be utilizing the new features or code. Instead your old hook will be processed and not the new code. Then you will think it is a cs-cart bug, but actually it was your hook causing the problem.



In my opinion hooks are not very useful if you are making a lot of changes. After each upgrade you will still need to do a lot of work to make sure your old hooks are not overwriting any new functionality.



Also, many features you may want to change are not within hooks and you will need to go several files back to find an appropriate hook.



For these reasons, and many others, I found it easier and more efficient to just rename the skin I am using (so cs-cart upgrades will not affect it) and not use hooks. After each upgrade I use the WinMerge (http://www.winmerge.org) program to compare files and see what has changed and update my custom skin accordingly. It only takes a few minutes to do this.



I believe the hooks were put into cs-cart for add-on development and not for skin modification. Yes, it sort of works for simple skin modiifcations, but advanced users beware.



David

[quote]

For example from 2.06 to 2.07 a lot of new functionality was added to the cart.

[/quote]



Could you provide a specific example? There should be no “functionality” within the hooks, only “presentation”.



No one ever said that using hooks will keep you current with the base if you are using code from the base. However, using hooks will get your store back up in minutes versus hours and allow you to review changes in your time, not in the time the developers have allotted for an upgrade.

One simple example, see my post here [url]http://forum.cs-cart.com/showthread.php?t=11307[/url]



If you use Winmerge to look at 2.06 to 2.07 you will see many files with changes within hooks.



As new functionality is added it is impossible for cs-cart to keep them outside of hooks.

Hi,



I’ve tried getting hooks to work. No luck. I’m using the “Default Green” template. Have verified that the actual template files have hooks embedded in them. My addon is “active”



I’m trying to build a “bottom.overide.tpl” hook.



I’ve tried placing the file in different folders, none of which work:



/addons/my_changes/index/

/addons/my_changes/hooks/index/

/addons/my_changes/index/hooks/



/addons/local/index/

/addons/local/hooks/index/

/addons/local/index/hooks/





Any suggestions?

[quote name=‘thenutrishop’]I’m trying to build a “bottom.overide.tpl” hook.[/QUOTE]

You need another “r” in overide - the filename should be bottom.override.tpl.



Bob

[quote name=‘jobosales’]

I hope that the developers will expand the conflict resolution in the upgrade to check to see if a hooked file exists when code is updated within a hook. They don’t need to (and really cannot) attempt resolution but they can let us know that we need to review our hooked files.

[/QUOTE]



After thinking it through, and upgrading yet again to v2.0.8, I do feel that I agree more and more with bob on this.



For me, I do not blindly modify/copy/apply hacks/addons/code to the cscart files.

I version control my source code in local drive (using Mercurial),

I ensure that for any modifications code I added, it will be commented properly, including adding my nick. (so if I need to, I do a “search all” for my nick and I can find back every single piece of code which I’ve edited before.)

I do differences comparison for each and every file before I do any upgrade, so I can ensure my modified code don’t get overwritten.



And even with these, sometimes I can forget that I’ve used a custom hook for that particular block of code.



As bob have mentioned, during upgrade, cscart can let us know that we need to review our hooked files. It will be very helpful.



To me, even a additional note in their changelog stating which hooks block have been modified would ensure that I will do the additional checks to ensure the compatibility of my code with the modified upgraded ones.



Something like:

```php

*v2.0.9 Changelog

The code within these hooks have been updated.

  • product:hook1
  • index:bottom
  • xxxx

    ```

    will help in the very least.

I have my_changes enabled



I created a folder “/cscart/skins/default_blue/customer/addons/my_changes”, and placed the file: “addon.xml” . Then I created a folder “index”, to which I added a file “bottom-override.tpl”. The code of this file is:

{hook name=“index:bottom.override.tpl”}

This is my footer. Copyrighted!"

{/hook}



I have saved everything, yet it does not work…please, what am I missing?

The file:



bottom.orverride.tpl



would need to be saved in:



skins/default_blue/customer/addons/my_changes/hooks/index/



Then your bottom.override.tpl file wouldn’t have the code that you have above. You can’t put the {hook} into this file because this file is the {hook}



For this file you would put what ever code you want to override the original file so in this case you would only have:


This is my footer. Copyrighted!



Basically you would fill this file with what ever code you want and it will become your footer.



Also I don’t know if it matters, but you don’t need a xml file in your:



skins/default_blue/customer/addons/my_changes



folder.



I hope this helps



Brandon