jobberBase Community

Welcome to jobberBase Developer Community!

You are not logged in.

Announcement

Announcement for new users: in order to combat the ever increasing spam, we no longer allow new users to post links in the message body. This limitation is automatically lifted once a new user has a specific number of 'valid' posts.

You can post links like google.com which will be rendered as text but you will not be able to post messages that contain complete URLs like www.google.com

Thank you for your understanding!

#1 2009-07-25 18:05:03

evertsemeijn
Senior Contributor
From: Netherlands
Registered: 2008-11-16
Posts: 378
Website

Easily switch themes

In this tutorial I'll explain how to make it easy to swicth templates on Jobberbase by adding less than 10 lines of code.

1. We'll start with the creation of a new folder in the root. I call it themes. In the themes folder we need to create a new folder named _cache which needs 777 permissions.

2. Once we have created the folder we need to open config.php and change

// Setup Smarty
	$smarty = new Smarty();
	$smarty->template_dir = APP_PATH . '_templates/';
	$smarty->compile_dir = APP_PATH . '_templates/_cache/';

into

/** change default in the name of your theme */
	define('THEME','default');
	/** This is needed so we don't have to change the location of the stylesheet */
	define('CSS', BASE_URL . 'themes/' . THEME . '/css');
	
/** Setup Smarty */
	$smarty = new Smarty();
	/** This is the new location of all themes */
	$smarty->template_dir = APP_PATH . 'themes/' . THEME ;
	/** This is the new location of the cache folder. Make sure it has 777 permissions */
	$smarty->compile_dir = APP_PATH . 'themes/_cache/';

Alright. Time to save config.php and upload it.

3. Now we are gonna move the template files to the correct location. Copy the folder _templates into the themes folder. Now rename _templates to default and remove the cache folder (_cache) from the default folder.

4. Open index.php and change

$smarty->assign('BASE_URL', BASE_URL);

into

$smarty->assign('BASE_URL', BASE_URL);
$smarty->assign('CSS', CSS);

5. The final step! Open themes/default/header.tpl and change

{$BASE_URL}_templates/css/screen.css

to

{$CSS}/screen.css

Adding new themes
1. Make sure the new theme folder, let's call it new_theme has the same structure as the default folder and upload it to the themes folder.

2. In config.php declare the name of the newly uploaded folder: change

define('THEME','default');

into

define('THEME','new_theme');

That should be all!!

Last edited by evertsemeijn (2009-07-25 18:24:01)


Member of Jobberbase Development Team - Templates/Usability :: Looking for installation and/or custom design? :: Beautiful Wordpress themes

Offline

#2 2009-07-25 20:00:55

redjumpsuit
rawkstar wannabe
Registered: 2009-01-16
Posts: 393
Website

Re: Easily switch themes

hey, i saw you posted this. i created a similar tutorial and saw that the idea is pretty much the same (i suppose when you work on templates it just makes sense to find a way to better handle templating than just crude customization on the default template.)

the approach i took was less invasive as i didn't modify the core file structure so that when you decide to upgrade when there is a new release, you don't have to re-apply this code to the affected folder and files again. you can see it here:

http://www.redjumpsuit.net/2009/07/20/j … technique/

the tutorial i wrote was originally sent to the redjumpsuit mailing list, then later on made available in my blog.

Last edited by redjumpsuit (2009-07-25 20:01:27)


www.redjumpsuit.net | jobberBase custom development and support

Offline

#3 2009-07-25 20:05:55

evertsemeijn
Senior Contributor
From: Netherlands
Registered: 2008-11-16
Posts: 378
Website

Re: Easily switch themes

Yeah, you're right. Your solution is best when you need to upgrade. I'll give it a try.

I was also think of creating different tags for the JS, IMG and CSS files. Just to make theming cleaner. This way

<link rel="stylesheet" href="{$BASE_URL}_templates/{$smarty.const.SKIN}/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="{$BASE_URL}_templates/{$smarty.const.SKIN}/print.css" type="text/css" media="print" />

can be

<link rel="stylesheet" href="{$CSS}style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="{$CSS}print.css" type="text/css" media="print" />

Think you get the point, right wink


Member of Jobberbase Development Team - Templates/Usability :: Looking for installation and/or custom design? :: Beautiful Wordpress themes

Offline

#4 2011-04-01 18:03:38

spongeproject
Member
From: Tewkesbury, UK
Registered: 2009-11-09
Posts: 50
Website

Re: Easily switch themes

I think I understand the code but wondered is there a similar version that enables an end user to choose a theme say from a dropdown option? Would like to have something for a demo site to showcase several templates.

Thanks

R


Jobatronic - templates & themes for Jobberbase
blog: Jobatronic blog - email: hello@jobatronic.co.uk - twitter: @jobatronic

Offline

#5 2011-04-12 19:49:22

spongeproject
Member
From: Tewkesbury, UK
Registered: 2009-11-09
Posts: 50
Website

Re: Easily switch themes

Anyone have any ideas?

R


Jobatronic - templates & themes for Jobberbase
blog: Jobatronic blog - email: hello@jobatronic.co.uk - twitter: @jobatronic

Offline

#6 2011-04-14 13:33:59

redjumpsuit
rawkstar wannabe
Registered: 2009-01-16
Posts: 393
Website

Re: Easily switch themes

you can try passing the template variable to a session then use the session as your current template. you'll need some php programming knowledge but shouldn't be so hard


www.redjumpsuit.net | jobberBase custom development and support

Offline

Board footer

Powered by FluxBB