Remembering a users template choice?

I'm surprised this doesnt do this- or did I miss something? I have multiple templates and when a user logs back in it defaults to my system default.

Any reason for this, or has someone determined why it happens?

Quote · 8 Jul 2010

2 reasons this could happen...

1 / The template is set by cookie - perhaps the cookie is getting deleted - get the user to check their browser settings

2 / The URL by which the site is accessed - if it ends in skin=YourTemplateName the template will be changed to that named.

HTH

/DM

Dolphin - Ajax Masturbation
Quote · 9 Jul 2010

I tested this on a few different browsers. Made sure cookies were enabled.

Another fellow elsewhere said basically that D7 doesnt do this, and that the hack/mod for it would be a simple one. (I'm still reeling at the fact that this isnt aleady a part of the code to begin with because who in their right mind would want to have to change to their favorite template every time they login?)

Im a novice at best, and grasp that you could do this more than one way, cookies being one, and another as a db entry. I'm not beyond approaching this myself but have no clue where to start.

Sorry, I forgot to ask you Dee, should D7 be actually remembering this setting then? If its a bug? Ive even tried setting the default uni as a choice and still no go.

The other fear I have is my experiences with some of these cms/social communities is anytime someone smells a buck they jump all over it for a 100$ price tag- I'm not from that crowd. (But thats only my opinion) I'm a UI author and have done templates over the years, knowing full well you can price yourself/present an attitude right into the piracy realm. Sorry for the rant, I just boggle at simple feature being left out of core while seemingly whacked out stuff like dependency on publishers servers gets put in. Dolphin so far has been good for me but maybe I'm just being picky after coming from so many other support driven communities... Wink

Quote · 9 Jul 2010

Ive been told that while the cookie type might be easier, using a php session method would be more secure. I'd like to pursue this or have someone point me in the right direction.

Even a snippet of similar code or a place to find it would help...

Quote · 9 Jul 2010

PHP sessions are temporary. And dolphin is not really setup to use them.

No. D7 does not set the template choice a permanent. It is a temporary cookie. You can make it a permanent cookie easy enough.

Open inc/classes/BxDolTemplate.php

At about line 174 look for this code.

function BxDolTemplate($sRootPath = BX_DIRECTORY_PATH_ROOT, $sRootUrl = BX_DOL_URL_ROOT) {
parent::BxDolMistake();

$this->_sPrefix = 'BxDolTemplate';

$this->_sRootPath = $sRootPath;
$this->_sRootUrl = $sRootUrl;
$this->_sInjecti alt= 'sys_injections';
$this->_sInjecti alt= BX_DOL_TEMPLATE_INJECTIONS_CACHE;

$this->_sCodeKey = 'skin';
$this->_sCode = $GLOBALS['MySQL']->getParam('template');
if(empty($this->_sCode))
$this->_sCode = BX_DOL_TEMPLATE_DEFAULT_CODE;

//--- Check selected template in COOKIE(the lowest priority) ---//
$sCode = $_COOKIE[$this->_sCodeKey];
if (!empty($sCode) && preg_match('/^[A-Za-z0-9_-]+$/', $sCode) && file_exists($this->_sRootPath . 'templates/tmpl_' . $sCode) && !is_file($this->_sRootPath . 'templates/tmpl_' . $sCode))
$this->_sCode = $sCode;

//--- Check selected template in GET(the highest priority) ---//
$sCode = $_GET[$this->_sCodeKey];       
if(!empty($sCode) && preg_match('/^[A-Za-z0-9_-]+$/', $sCode) && file_exists($this->_sRootPath . 'templates/tmpl_' . $sCode) && !is_file($this->_sRootPath . 'templates/tmpl_' . $sCode)) {
$this->_sCode = $sCode;

$aUrl = parse_url($GLOBALS['site']['url']);
$sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';

setcookie( $this->_sCodeKey, $this->_sCode, 0, $sPath);


The red line is where the cookie is set. the 0 in that line specifies that the cookie is to expire when the browser is closed. To change that to a somewhat permanent cookie change the 0 to time()+2592000

This is expire in one month. Current time (time()) + number of seconds to be added to current time.

https://www.deanbassett.com
Quote · 9 Jul 2010

I've been thinking about this myself.  I'd like a way to store the users template choice in the DB, and not have to rely on a cookie being on the users machine.

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 9 Jul 2010

Same section of code. Where it sets the cookie you can write to the database instead. And above that is where the cookie is read. That could be replaced with code to fetch from the database.

Will work on something when i get a few minutes.

https://www.deanbassett.com
Quote · 9 Jul 2010

Dean, thanks for looking at this and posting a response! Since you are actually doing the work here, I suggest you wrap it up as a mod with your name attached. I'm still getting SE and PHPFox coding out of my head and it'd be quite sometime before I could even come up with something like this.

Again, many thanks!

Quote · 9 Jul 2010
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.