Mr.Z Posted March 25, 2010 Share Posted March 25, 2010 Is there any way to have different themes based on the category that is selected? In resume how can i change the current theme through code?Thanks Link to comment Share on other sites More sharing options...
rocky Posted March 26, 2010 Share Posted March 26, 2010 How were you wanting to do this? Do you have multiple themes in your themes directory and you want to switch between them or do you want to create a single theme that has multiple themes built in to it? The current theme is specified in config/settings.inc.php: define('_THEME_NAME_', 'prestashop'); You could try using code like the following at the top of init.php to change the theme depending on the current category: if (isset($_GET['id_category']) AND $GET['id_category'] == 2) define('_THEME_NAME_', 'category2'); if (isset($_GET['id_category']) AND $GET['id_category'] == 3) define('_THEME_NAME_', 'category3'); This code would make category 2 read themes/category2 and category 3 read themes/category3. Any other page will display the original theme in settings.inc.php.Let me know if this is what you want or whether you want all category themes integrated into a single Prestashop theme. 1 Link to comment Share on other sites More sharing options...
Mr.Z Posted March 30, 2010 Author Share Posted March 30, 2010 Thanks rocky, That's exact what i need. But it didn't work because the init.php is included after the config.inc.php, that is where the theme dirs and images are set, plus constants can't be redefined, so once the _THEME_NAME_ is in the settings.inc.php i can't change it anymore.So, until now i couldn't think any solution to do that. =(any clue? Link to comment Share on other sites More sharing options...
rocky Posted March 31, 2010 Share Posted March 31, 2010 Can you comment out the theme name definition in config.inc.php and then use the following? if (isset($_GET['id_category']) AND $GET['id_category'] == 2) define('_THEME_NAME_', 'category2'); elseif (isset($_GET['id_category']) AND $GET['id_category'] == 3) define('_THEME_NAME_', 'category3'); else define('_THEME_NAME_', 'default'); Link to comment Share on other sites More sharing options...
Mr.Z Posted March 31, 2010 Author Share Posted March 31, 2010 Yes, but as you said, only for category pages.I have implemented a "cookie read" to set the _THEME_NAME_ and trough produtct.php and category.php i set a cookie with right theme name. =)Thanks. Link to comment Share on other sites More sharing options...
shake Posted April 16, 2010 Share Posted April 16, 2010 Mr.Z any chance you can post how you did this please. cheers Link to comment Share on other sites More sharing options...
Timpet Posted June 27, 2010 Share Posted June 27, 2010 the abov could be used with google website optimzer calling the URL something like www.your-shop.com/index.php?theme=1 and for a new theme variation www.your-shop.com/index.php?theme=2 and then perhaps use .htaccess for a rewrite of it to make in pretty. Link to comment Share on other sites More sharing options...
Recommended Posts