View Single Post
  #5  
Old 08-23-2012, 04:19 AM
  xplorer's Avatar 
xplorer xplorer is offline
 

X-Cart team
  
Join Date: Jul 2004
Posts: 925
 

Default Re: Custom skins hierarchy

Hi!

Let me explain how this works.

Think of a pie made of multiple layers. Each layer is a skin directory added by an X-Cart Next module.

First of all, X-Cart Next loads enabled modules. When it finds a module registering a skin directory it puts the directory on top of the previous one.

Then, when loading a template or a resource file, X-Cart Next goes through all the layers from the top. When it finds the file it stops and doesn't look in "lower" directories.

So, the order in which X-Cart Next goes through skin directories when looking for a "skin" file is the reverse order in which it loads modules registered the directories.

What is the order in which it loads modules? First of all X-Cart Next loads modules which other modules depend on. Then it loads the rest alphabetically.

An example:

Quote:
Let's say you have three modules that register their skin directories: Clean (skins/clean), Fancy (skins/fancy) and Zen (skins/zen). Clean module states (in Main.php) that it depends on Zen module.

X-Cart Next will load the modules as follows:
Zen -> Clean -> Fancy.

That means that the order in which it looks through registered skin directories will be as follows:
skins/fancy -> skins/clean -> skins/zen -> skins/default

Now let me explain the difference between "skins/[custom]/" and "skins/default/en/modules/[dev]/[module]/" directories:
- when you create a new widget or a template, you place its files into the "skins/default/en/modules/[dev]/[module]/" directory
- when you want to replace an existing template, you place your file into the "skins/[custom]/" directory.

Take a look at the following example and you'll understand the idea behind this:

Quote:
Let's say you want to display currency exchange rates in a sidebar.

You create a custom module that adds the new template file:
skins/default/en/modules/Totaltec/CurrencyRates/sidebar-block.tpl

Now you realise that you need the same feature on another website, but with a different template.

You copy the module and install it there. To alter the template file you:
- create another module that registers the new skin directory (skins/myskin)
- put the modified template file into skins/myskin/en/modules/Totaltec/CurrencyRates/sidebar-block.tpl

Now you can fix bugs in the original Totaltec/CurrencyRates module and upload it to both the websites without having to adapt it for your website skins.
Reply With Quote