Creating additional styles for the template

Creating additional styles for the template was created by Boradan

Posted 10 years 1 month ago #17882
Hi. I have created an additional style for my template which the end user can select using a dropdown box, but am having a small issue with the necessary code to select it.
The code in the index.php is php (d'uh'), and I have no idea how to code for this.

So far, the code I am using is just modified from the default index.php where it chooses template.css or template_rtl.css.

original code:
Code:
<?php if ($this->direction == 'rtl') { ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template_rtl.css" type="text/css" /> <?php } else { ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" /> <?php } ?>

I have modified this to:
Code:
<?php if ($this->direction == 'rtl') { ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template_rtl.css" type="text/css" /> <?php } else { ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/<?php echo $this->params->get('style') ?>" type="text/css" /> <?php } ?>

and I have created a dropdown selector box in the template advanced parameters with:
Code:
<field name="style" type="list" default="template.css" label="Website Style" description="Choose between the four available template styles for your website" class="list"> <option value="template.css">Default</option> <option value="dark.css">Dark</option> </field>

This is inserted into the templateDetails.xml file.

All is working fine and I can select the second style sheet (dark.css) and it is applied correctly to the site.

What I would like to know is how I can utilise this function with the template_rtl.css?
As it stands, the 'dark.css' can only be used if the site is not RTL.
How can I word the coding so that it can use 'dark_rtl.css' if dark is chosen and the site is RTL?
I could do this by removing the if > else statement and just adding template_rtl.css and dark_rtl.css to the dropdown, but the user would have to select the correct style if they used rtl, and I would like to eliminate that.

I know this is WAAAAY outside the remit for any support, but would just like a few pointers as to how to get this working correctly.

Would be amazing if you could add the ability to add different styles within template creator, but I realise this is probably a LOT of work.
Last Edit:10 years 1 month ago by Boradan
Last edit: 10 years 1 month ago by Boradan.

Please Log in or Create an account to join the conversation.

Replied by ced1870 on topic Creating additional styles for the template

Posted 10 years 1 month ago #17884
Hi
this is a very specific request and needs some PHP skills.
I would do that
1/ in the options, use
<option value="dark">Dark</option>
(without .css)
2/ in the php
Code:
<?php if ($this->direction == 'rtl') { ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/<?php echo $this->params->get('style') ?>_rtl.css" type="text/css" /> <?php } else { ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/<?php echo $this->params->get('style') ?>.css" type="text/css" /> <?php } ?>
;)
CEd

Joomlack Webmaster and Developer

by ced1870
The following user(s) said Thank You: Boradan

Please Log in or Create an account to join the conversation.

Replied by Boradan on topic Creating additional styles for the template

Posted 10 years 1 month ago #17886
man, thats sooooo simple. I feel like an idiot for not figuring that one out myself.

But now I have the ability for the end-user to select different styles. Thanks very much for the quick pointer :D
by Boradan

Please Log in or Create an account to join the conversation.

Time to create page: 0.657 seconds

Fast and powerful creation, customizable and responsive.

Read More

We have 980 guests and no members online