Load Stylesheet based on user input - Joomla! Forum - community, help and support


hello,

i have developed first template , working alright. create option in user can select template color load appropriate stylesheet. example : have 5 stylesheets - default.css, blue.css, green.css, red.css , orange.css. provide backend option user user can choose 5 colors dropdown menu in template backend , load stylesheet associated color. have considered option of duplicating template , editing css, makes template size large , avoid if could.

thanks in advance :)
sai.

i have figured out how this. incase else wondering how accomplish this
1)create folder called "colors" inside template's css folder. place template colors inside , ensure named red.css, blue.css etc.,

2) open templatedetals.xml file , add code below in "fieldset" section
<field name="themecolor" type="list" default="default" required="true" label="select template color">
<option value="blue">blue</option>
<option value="red">red</option>
</field>

3) add variable themecolor in php file have declared variables , code below
$tpath = $this->baseurl.'/templates/'.$this->template;
$themecolor = $this->params->get('themecolor');
$_session['themecolor'] = $themecolor;

4) add code below index.php file change template color based on user input
<link href="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/css/colors/<?php echo $_session['themecolor']; ?>.css" rel="stylesheet" type="text/css" />

for work "option value" field should same template color css file. example if have option value red, must have red.css file in colors folder.

i hope helps looking similar solution.

cheers!
sai.





Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support