Latest articles
Latest articles of category




Templates - File Structure


Before start coding you need to know exactly where to find what. Two are the main folders that our CMS template system make use.

The first one mentioned previously on introduction page and that is the templates_c folder. That folder needed for Smarty to compile the templates. It needs to have 777 permission or 755 if you are running PHP with SuPHP module installed and configured.

Templates_c
It is highly recommended to put your templates_c folder outside the public web site folder in order to avoid any security issues with 777 permissions.
As soon as you move the folder do not forget to open includes/settings.php to update templates_c path to the new one.

Assume you have a shared hosting account where your public folder is /home/username/public_html. Then you will need to create the folder on /home/username and chmod that.
The following two commands will do the trick:

mkdir /home/username/templates_c
chmod 777 /home/username/templates_c

SuPHP
suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter.
By having suPHP enabled you need to chmod each folder 755 and any file 644 thus giving you great flexibility on security.

All templates are under templates/themes/ and this is where a new template must be placed. In our example we will use the portalblue template which is the default template of Guru CMS.
The following files and folders exist under a typical template with all modules installed.


announcements.tpl
announcements_all.tpl
article.tpl
authorsArticle.tpl
comments (folder)
contactUs.tpl
content.tpl
css (folder)
footer.tpl
header.tpl
images (folder)
indexFooter.tpl
indexHeader.tpl
latest.tpl
menu.tpl
newsletters (folder)
rss (folder)
search.tpl
sitemap.tpl
staticArticles.tpl
userAuth (folder)
view-gallery.tpl

Extra Folders
Folders named comments, rss, newsletter, creditSystem and forum are all available only when you bought any or all of these modules. Those modules cost extra and are available upon request.

In order to install a new template you can just copy-paste the portalblue template to the same folder with a different name. In Linux you can do this from a terminal by typing cp -a portalblue newTemplate where newTemplate is the name that you want to have. Then go to the administration menu, click on Templates and Add Template link. Type the same name as you did previously (newTemplate) and click submit. That's it; the new template is in place. You can now modify it straight away. You can do this via ftp or direct via a web interface. Just click Edit Template and you will be able to edit each template file individually.

This is recommended if you want to make minor changes as any change will affect the public web site unless you don't care about it. An alternative is to set the web site into the offline mode and as soon as you finish swapping it back to online.

The most common way to develop a template is to create/modify the template locally to your machine/server and then upload it to the public site. This will give you great flexibility.

Posted on: 23/03/2011