Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Custom skins hierarchy

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-21-2012, 09:40 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Custom skins hierarchy

How is the hierarchy of skins defined? If I want to create a custom skin for XCN, do I have to disable the XCNSkin module? Or can I create a new skin that will overridethe XCNSkin? How would priority be determined between skins?
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #2  
Old 08-22-2012, 12:45 AM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: Custom skins hierarchy

Totaltec,

If you have the version where the xcart skin is a module, you need to install the latest version. The skin named default is xcn in this version. http://next.x-cart.com/download/trial

Priority is always with the default skin and the template engine overrides the default skin with yours. This way you only have to replace the parts you require.

It would be useful to look at the xcn skin to get an idea of how it all works. There two places where replacement skins are placed currently. (odd to me)

skins/default/modules/<Your DevId>/<Your Module>

this is for your modules obviously. Notice that XLite\Module\ where you place your module does not have an 's' on the end but the default/modules does. Just pointing it out as when you type a namespace in it's easy to make a mistake and wonder for hour or so as to whats wrong

and

skins/<your skin name>

If you go litecommerce.com and follow the link through to the wiki you will find some useful if not confusing information.

Skinning the Drupal version is much easier believe it or not.
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote

The following user thanks Cpt.Crashtastic for this useful post:
totaltec (08-22-2012)
  #3  
Old 08-22-2012, 05:53 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Custom skins hierarchy

Thank you Captain! I have skinned the Drupal version of LC, I agree it is easier. I have also successfully skinned the stand alone version now (just last night). I am still confused though, for a while I had my new skin enabled, and the XCN skin enabled, and my skin seemed to be overwriting the XCN skin. Not sure if it is because it initialized first, or what.

I am still curious if there is a hierarchical order of skins, and how that is determined if it exists. This would be pretty important, if you wanted to sell an XCN skin, you would want to know if you should instruct users to disable their existing skin, or if you could code it to put your custom skin first in priority.

I'll download the latest version soon, I am still working on the extremely old beta version that was released 2 whole weeks ago.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #4  
Old 08-23-2012, 12:56 AM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: Custom skins hierarchy

It looks like you could have several skins loaded so you would have to tell customers to disable existing skins. It would be handy if there was an Appearance setting like in Drupal. CDev I guess would have some priority but any others I don't know without experimenting. Maybe I'll find time to try today.
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote
  #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

The following 2 users thank xplorer for this useful post:
Cpt.Crashtastic (08-23-2012), totaltec (08-23-2012)
  #6  
Old 08-23-2012, 05:19 AM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: Custom skins hierarchy

Thanks V

Now i understand. Thats really useful information.
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote
  #7  
Old 08-23-2012, 06:19 AM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: Custom skins hierarchy

Continueing this hierarchy discussion further

If we take for example Minicart.php the list position is specified before the class declaration.

We can extend this class and change the position of the list, for example to the sidebar, in the same way as the original, but this results in there being two positions. The original position and the new position.

Is it just a simple matter of including a blank template (header.right.tpl) within our new skins or is the better way to deal with this? Having a blank template doesn't seem right to me.
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote

The following user thanks Cpt.Crashtastic for this useful post:
totaltec (08-24-2012)
  #8  
Old 08-24-2012, 03:47 AM
  xplorer's Avatar 
xplorer xplorer is offline
 

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

Default Re: Custom skins hierarchy

You can move and replace existing widgets and templates by declaring runBuildCacheHandler() method in your Main.php file as follows:

HTML Code:
/** * This method runs at the end of the cache rebuilding process. * * @return void */ public static function runBuildCacheHandler() { /* * Items in XLite\Model\ViewList have the following attributes: * - 'list' - the full identifier of the "view list" in which * the item is to be displayed * - 'child' - the full class name of the widget to be displayed * - 'tpl' - the template file to be displayed (path to the * file inside the "skins/[skin-name]/[language-id]/" directory) */ $item1 = \XLite\Core\Database::getRepo('XLite\Model\ViewList')->findOneBy( array( 'list' => '[current_view_list]', 'child' => '[widget_class]', ) ); if ($item1) { // Now you can move the widget to another "view list" $item1->setList('[new_view_list]'); // ... or replace it with a custom widget class $item1->setChild('[custom_widget_class]'); } $item2 = \XLite\Core\Database::getRepo('XLite\Model\ViewList')->findOneBy( array( 'list' => '[current_view_list]', 'tpl' => '[relative_path_to_template]', ) ); if ($item2) { // Move the template to another "view list" $item2->setList('[new_view_list]'); // Replace the item with a custom template file $item2->setTpl('[custom_template_path]'); } if ($item1 || $item2) { // Push the changes into the database \XLite\Core\Database::getEM()->flush(); } }
Reply With Quote

The following 2 users thank xplorer for this useful post:
Cpt.Crashtastic (08-24-2012), totaltec (08-24-2012)
  #9  
Old 08-24-2012, 03:54 AM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: Custom skins hierarchy

Now that is really useful. Thanks Vyacheslav
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:02 AM.

   

 
X-Cart forums © 2001-2020