get started with PHP themes

1) "CSS ZEN"

This is where the markup remains unchanged, but you totally change the design just by using CSS and images. Demonstrated very well on

cdl_capture_2011-03-05-37_ 000

2) MVC Stylee

This is where you create a model that represents the page data and then pass it to a view, which contains some inline echo statements. The idea is that you could send the same model to a totally different view so it could look entirely different, HTML and all. Cake PHP is a good start for this:


<div class="content">
    <? echo $Page->Content ?>

3) Micro-Markup

With this method, you add your own "special tags" to an HTML page. You then read in your plain HTML page and replace the special tags with the information you want to display. This is good if you want your templates to be recognisable to HTML guys that don’t know PHP and might break the PHP code in the MVC app.


<div class="content">

Out of all of these, MVC is a very structured way of achieving what you want – however, I listed the other options as they cater for specific scenarios that might be relevant to you.

I have implemented the concept in all three of these, in situations that were appropriate for each.

Regarding The Edit In The Question

I imagine you’ll have "something" that represents your user – so it is as easy as:

(In the event of just wanting to override a few settings…)

<link href="style.css" type="text/css" rel="stylesheet">
<?php if ($User->Type === USER_ADMIN) {  ?>
<link href="admin.css" type="text/css" rel="stylesheet">
<?php } ?>

You can adjust this example in the following ways:

  • Use a switch statement if there will be many user types
  • If the replacement is total, rather than just a few overrides, you may want to completely swap the stylesheet.

Leave a comment