CodeClerks

How to add template change function in PHP?



Enter a reason for deleting this comment

How to add template change function in PHP?

When sites update their template they give you the option to revert back to the old theme. How exactly is this done? Generally, you could add new files to the theme/template folder, or even create a new directory for the theme, but what is the best way to get this done via the database?

You could add something like:

<<?php echo $data['style']; ?>.css" media="screen" rel="stylesheet" type="text/css" />


But how would you do this with a function, so you don't have to use a directory?

 

Comments

artbluelove

Hi, I have website and template. I could add new files to the template with my rental server.
But I still don't have the best idea. 
I didn't write code, like your code :
<<?php echo $data['style']; ?>.css" media="screen" rel="stylesheet" type="text/css" />
In addition, I use directory.. why not they could..



Enter a reason for deleting this comment

ultimate

What I generally do is to store users theme preference in a database. For each theme there is a directory containing 3 (or more) sub-directories CSS, IMAGES, JS. Now, in you just pass the theme name to the view (html) and call files from that folder corresponding to the users theme.
Make sure you have a 1:1 map across all themes or things will break.



Enter a reason for deleting this comment