The PHPTEMPLATE Engine for Drupal 5.x has a new feature that automatically loads page-layout.tpl.php files as soon as you upload them to your active theme folder. In other words, if you upload a page-blog.tpl.php file to your active theme folder, you don't need to tell template.php.
For example, build page stucture in the following suggestions:
page-default.tpl.php
page-admin.tpl.php
page-front.tpl.php
page-blog.tpl.php
page.tpl.php
etc..
Procedure
A simple example would be using the following path to tell Drupal to load a custom page-admin.tpl.php layout file.
e.g. If the current path is www.example.com/admin/* The arg(n) variable is therefore "admin" and we can use that to tell Drupal to load a page-admin.tpl.php.
Step 1 of 2
1. make a copy of your page.tpl.php file and rename it to be page-default.tpl.php.
2. make further copies your page.tpl.php file it and rename them to be page-front.tpl.php, page-blog.tpl.php and page-book.tpl.php etcetera..
3. using a text editor like notepad.exe or equivalent, modify the layout of each tpl.php file to suit your desires
4. upload your new page-type.tpl.php layout files to your active theme folder
Step 2 of 2
1. Using a text editor like notepad.exe or equivalent, replace the contents of your page.tpl.php file with the snippet below
2. Ensure that you have a page-default.tpl.php file as part of your collection of layouts.
3. Upload your new page.tpl.php file to your active theme folder and your new layouts will take effect automatically
<?php
/**
* This snippet loads up different page-type.tpl.php layout
* files automatically. For use in a page.tpl.php file.
*
*/
if (arg(0)=="admin") {/* check if the path is example.com/admin */
include 'page-admin.tpl.php'; /*load a custom page-admin.tpl.php */
return; }
if ($node->type == 'blog') {/* check if the path is example.com/blog */
include 'page-blog.tpl.php'; /*load page-blog.tpl.php */
return; }
/*insert more layout calls here before the call to page-default.tpl.php */
include 'page-default.tpl.php'; /*if none of the above applies, load the page-default.tpl.php */
return; }
?>














Post new comment