Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Suggestion for Better Template System


Parikesit

Recommended Posts

Long time not been here, I got the current version of OsC (ver. 2.3.1) already had template system. well, it is a good idea, but still need an improvement. For example, we can not dynamically change the template (theme).

 

I have many ideas for the improvement, but as an initial I recommend the following step:

 

  • First: we need to create better structure (folder organization).
    We need to move template_top.php & template-bottom.php to other folder. My suggestion is to create a themes folder in OsC directory, and create a new theme inside that folder.
     
    The folder themes will be (see the attachment for detail)
    + themes
     + myfirsttheme
       + css
       + images
       + javascript
       - template_top.php
       - template_bottom.php
     + mysecondtheme
       + css
       + images
       + javascript
       - template_top.php
       - template_bottom.php
     + mythirdtheme
       + css
       + images
       + javascript
       - template_top.php
       - template_bottom.php


     
     

  • Second: edit includes/configure.php, and add DIR_WS_THEMES
    define('DIR_WS_THEMES', 'themes/');


     

  • Third: add THEME configuration_key to configuration table.
    INSERT INTO `configuration` (`configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`)
                        VALUES ('Theme',  'THEME',  'default',  'The name of theme used',  '1',  '999', NULL ,  NOW(), NULL , NULL);


    So, to change the current theme just go to Configuration > My Store > Theme
     

  • Fourth: edit all catalog files, and find the following lines:
      //require(DIR_WS_INCLUDES. 'template_top.php');
     //change to:
     require(DIR_WS_THEMES . '/' . THEME . '/template_top.php');


     

      //require(DIR_WS_INCLUDES. 'template_bottom.php');
     //change to:
     require(DIR_WS_THEMES . '/' . THEME . '/template_bottom.php');


post-541-0-86490800-1311001950_thumb.jpg

Link to comment
Share on other sites

  • First: we need to create better structure (folder organization).
    We need to move template_top.php & template_bottom.php to other folder. My suggestion is to create a themes folder in OsC directory, and create a new theme inside that folder.

 

 

Forgot to mention another file to be moved: includes/header.php

Link to comment
Share on other sites

Currently I'm doing this modification for a new OsCommerce site. And I found that current template class (oscTemplate) was very plain and limited. On other side, OsCommerce has been developed without 'template system' in mind: separating code, content and layout/design.

 

For example, all modules in includes/modules directory need to be reworked (or moved to folder themes/theme), because most of them directly output the content and layout . And also all files in ext directory, like jQuery, etc. Well, I guess its bad idea to attach OsC to any of Javascript framework and depend on it--especially for frontpage.

 

Duh, can not wait for OsC version 3...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...