Skip to content

dart-creations.com

Advertisement
Home arrow Forums
Print E-mail

 #30 - Sticky Template Chooser (or allowing your users to choose their own Joomla template)

The Template Chooser, is one frustrating module. The first time you see it, you think that it's there to allow your users to choose their own templates. You enable it and leave it there, but you realise that it actually reverts to the default template.

With this small hack, you can ensure that the Joomla template your users choose via the Template Chooser, remains there always (or at least as long as the cookie lasts Laughing)

Find the following lines in includes/joomla.php. There's a cookie setting for the tempalte which lasts only 10 minutes. To extend it, reset the time to your choosing. In Joomla 1.0.13 see lines 1288-1295:

// check that template exists in case it was deleted
if (file_exists( $mosConfig_absolute_path .'/templates/'. $jos_change_template .'/index.php' )) {
$lifetime = 60*60*24*365; // *dr* change it from 60x10 (=10 minutes) to 60*60*24*365 (=365 days) to save template choice for 365 days;
$cur_template = $jos_change_template;
setcookie( 'jos_user_template', "$jos_change_template", time()+$lifetime);
} else {
setcookie( 'jos_user_template', '', time()-3600 );
}

That's it ... your user choosable template now lasts for a year. 

Comments
Search RSS
Admin  - Great   |222.240.253.xxx |2008-02-02 20:31:07
tnx man, great help
Kayax  - Very nice!   |205.200.11.xxx |2008-06-11 16:29:06
Thank you for showing us how to do it!
Now my users don't need to fight with my
templates all the time!
Martin  - Save choice by menuid?   |213.169.107.xxx |2008-07-01 07:26:14
Great tip! Any idea on how to change the core functionality so that it saves the
cookie/template based on menuid? I am using several templates on my site
(assigned to different menu items), and the current functionality of template
chooser overwrites the assigned templates (the user-selected one shows up
everywhere). Any ideas would be appreciated!
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Buy us a beer!

If we've helped you, consider buying a beer €3. It will inspire us to keep on giving! Cheers!

Sponsors

Login Form






Lost Password?
No account yet? Register

Pagerank
Generated in 0.32757 Seconds