WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: nickname on March 15, 2012, 05:32:31 PM

Title: Show logged in user a diffrent template
Post by: nickname on March 15, 2012, 05:32:31 PM
Hello,

thats pretty much my first question since... I don't know (But I am not new to WB, I use it for 3 years now and I've written various modules, so keep it advanced :wink:).

Right now I want to test a new design. But not with a testinstalation, but in real. For that I thought I would just add the option to show the loggedin user a different template, than the normal visitor.

I found where the Template is defined and there I wanned to add this function (manually, because I don't need it work perfectly)

This is in the class.frontend.php of WB 2.8.3 on line 196
Code: [Select]
// Figure out what template to use
if(!defined('TEMPLATE')) {
if(isset($this->page['template']) AND $this->page['template'] != '') {
if(file_exists(WB_PATH.'/templates/'.$this->page['template'].'/index.php')) {
define('TEMPLATE', $this->page['template']);
} else {
define('TEMPLATE', DEFAULT_TEMPLATE);
}
} else {
define('TEMPLATE', DEFAULT_TEMPLATE);
}
}

Anyone has a idea how to make this possible?

Thank you for your help
Title: Re: Show logged in user a diffrent template
Post by: Stefek on March 15, 2012, 07:37:32 PM
You can make it with a standard template.

Use the index.php of your template to check if the user is logged in.


Code: [Select]
<?php
if($wb->is_authenticated()) { 

     include(
'template_visitors.php');

 }else{

     include(
'template_authenticated.php');

}
 
?>


No need to hack the core to do this.

Regards,
Stefek
Title: Re: Show logged in user a diffrent template
Post by: nickname on March 15, 2012, 10:16:35 PM
Thank you for your reply

Yeah, but this does not work quite that pretty.
I need to move all the files, which are at the moment in to folders, to one folder, in order to load the css and the js. Also I need to rename the css and js files (because they have the same name, like in the other template).

Sure it would work, but isn't there a way to actually keep the templates seperated and still use two?
Title: Re: Show logged in user a diffrent template
Post by: Stefek on March 15, 2012, 10:42:28 PM
I don't know if there is another way.
I understand your issue with two templates - but if you think over it, it may be the better solution for you.

I don't know how much both templates differ.
Maybe you need only some parts of it to be different. If so, my solution will work good for you and you will need only to rework ONE directory if you want to make changes in the future.


Regards,
Stefek
Title: Re: Show logged in user a diffrent template
Post by: Tez Oner on March 16, 2012, 03:15:26 AM
Eey,

maybe it can work out with calling the templates with a 'var' defined in the page or url of the page
(I use this code in my Template Framework 3 (http://revamds.com/modules/download_gallery/dlc.php?file=30 (http://revamds.com/modules/download_gallery/dlc.php?file=30)) which creates a 'template-framework-layer' to have multiple styles/layouts on one template-install.

Code: [Select]
$scheme_name_var='MobileMaps';

or like this:

<link rel="stylesheet" type="text/css" href="http://www.mobilemaps.nl/templates/va_template_framework_3/css/css_index.php?scheme_name_var=MobileMaps" />

$scheme_name = $_GET['scheme_name_var'];
$scheme_name = $scheme_name;

<?php $values_path "schemes/$scheme_name/values.$scheme_name.php";include $values_path?>
<?php $scheme_path "schemes/$scheme_name/scheme.$scheme_name.css"?>

You maybe need to customize it to your own needs but can be another direction/road of thinking... ;)
The Template Framework is free to download.

Cheerz,

Tez