An original theme : rocheblog

traditional way of writing a template
fig. 1

Among all the WordPress themes that I had the opportunity to see until now, I found that all the php template files they use are written the same way, emphasizing the html compared to php.

Let me clarify my point of view : these templates are written as an HTML page and PHP functions are « added » by chains such as:

<?php instruction_or_function( ); ?>

 

Visually, with a text editor like NotePad++, this gives what we can see in the example of Figure 1. With this approach, it is difficult to find your way in the code as soon as you have a conditional function (if, else, etc ...), or a loop function (while, etc ...).

 

another way to write a template file
fig. 2

... Then I thought, why not write these template files as I usually do when I write any PHP file : I start the script with a « <?php » and end it with a « ?> », quite simply. I use a double slash for all the comments (or possibly /* comment......... */), the good old echo "" function for generating the HTML code.

I complete by « backslash t » for tabs, and « backslash r backslash n » for newline.

My if, else instructions are followed by braces ({ for the beginning, and } for the end). Same thing for the while instructions, and so on...

And believe me, I sort thing out much better.

I add a little indentation in the PHP code (see Figure 2) to better find my way, and it works flawless.

The only tricky thing to do is to escape " by backslashes in the argument of the « echo » functions. ideal work tool for that : NotePad++. Only looking at the appearance of the code, you can see right away if there is an error or omission.

That said it all. My template is available for downloading below. This is my modest contribution to this great CMS : WordPress (when you hold us, you will not let us more...).

Downloading the « rocheblog » theme

The archive rocheblog.zip (version 1.1) contains all the information necessary to use this template in your site. The images used as head and footer were deliberately blurred. If you want to get the hang with Gimp, you can rework the images of head and footer : tete_de_base.xcf (header) and pieds_de_base.xcf (footer). You just have to add as many layers as added elements. Good luck !

Your feedback

If you enjoyed this article (or disliked), you would be nice to leave a comment on the page of your choice :