• Advertisement
Sign in to follow this  

[web] Setting webpage UI theme change in PHP - Howto

This topic is 4256 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently redoing my personal website in PHP and I want to build it from the ground up. I know a little bit of PHP (a novice to be honest) as I like its syntax (it reminds me of my fave language C/C++) Anyway, I want to create a site, where the user can change the webpage theme like for example the brilliant and highly recommended Spoono tutorial site, which allows you to change the theme by clicking on one of a few flavor icons on the menu bar above. I know that you use variables, and when you load each variable you load the HTML page template. Im not sure how this is done. Can someone please give me a hint on how to implement it, or any tutorials on how i can approach it, help would come greatly appreciated. Regards

Share this post


Link to post
Share on other sites
Advertisement
Well, if i'd have to do something like that, then this is how i would do it:
1) i would create a directory for themes.
1.1) i'd put all themes (templates, images, CSS, javascript) into a subdir of this themes directory.
1.2) i'd create a config script inside themes directory (this is where i would put all the names and id numbers of all themes).
2) I would organize my themes so that all of them has required configuration script.
3) When user loads some page, i'd check for cookie
3.1) no cookie or cookie is not valid => i load default theme (found in theme config - 1.2).
3.2) cookie is valid => i load theme whos id is in the cookie.
4) When user clicks on a theme link (he wants to change it), i'd check if it's valid.
4.1) New id is not valid => leave it as it is now.
4.2) New id is valid => store the new id in the cookie, load the page using the new theme.

I'm not sure what else is needed here. Well, it might be harder if you're not using template engine (like smarty), but it shouldn't be very hard.

Share this post


Link to post
Share on other sites
Thanks Paulius as that has given me an insight on how to full this off. Setting up directories for templates and sub directories for images is definately my first step. I have just one query, what is Smarty? im a relative unknown to PHP... I am going to plan this out, but i want to set all my options... Is there any sites where i can see examples in psuedocode or hard code, so i can see how to set my site up. All i want to do is see an example, so i can rewrite my own version...

Share this post


Link to post
Share on other sites
Smarty is very powerful and fast PHP template engine writen in PHP.
I don't know of any easy to understand tutorials or explanations. But most of the Content Management Systems and forums has this, so you could find some open source projects and look at it.

Share this post


Link to post
Share on other sites
Thanks for your reply Paulius. As im looking at Smarty and it looks exciting. I will definately be researching on this template engine. I will get this looked at...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement