Question

Websites like Wordpress and Tumblr allow designers to create themes that users can select. In general how would you architect a website to be flexible enough to allow custom themes for users?

Was it helpful?

Solution

Take a look on how Django does it. Django uses a Model-View-Controller-like approach in which you use views to populate a context, and then use that context to process a template. Note that Django has its own MVC terminology.

For example, if we say that our context reads as follows (in pseudo code),

author = 'mntnoe'
title = 'My Title'
content = '<p>This is my content</p>'

we could use the following template:

<h1>{{ title }}</h1>
<div class="author">Author: {{ author }}</div>
<div class="content">
{{ content }}
</div>

Now, you are free to replace the template (or collection of templates) with another one without affecting how the site works.

OTHER TIPS

Seperate content from formatting by using proper html and css. That means using css files for the style rather than inline style inside the html.

You can make several css files (themes if you wish), and switch between them using javascript.

Let your serverside technology of choice simply generate easy to adjust, by css and images, html. A great site of examples is http://www.csszengarden.com/. It emits the same html every time but uses different css and images to style it. Take a look at the html they generate to get ideas.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top