Page Templates:Creating a Basic Template

From Whirlwind eCommerce Wiki
Revision as of 19:56, 3 December 2008 by Root (Talk | contribs) (New page: {{Page Template Managers Shortcuts}} == Create basic template == This example will help provide a good introduction to templates. While there are dozens and dozens of [[Page Templates:Fun...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Page Template Managers

Create basic template

This example will help provide a good introduction to templates. While there are dozens and dozens of functions and core variables available, this template example will focus on just a few of the core variables and the menu bar functions to get your feet wet.


// always start your templates with any functions you require
// to gather the data you need for the page
 
// lets start by getting our menu bar data
// note that the menu bars are usually contained in component includes
// since they are reused on many templates, no reason to perform the task on each template
$menus = eV::pageMenuGet();
// for easy reference, lets separate the menus
$topMenu = $menus['t'];
$leftMenu = $menus['l'];
$bottomMenu = $menu['b'];
 
 
// lets build an outer table to hold our page content
echo "<table width=779>";
 
// this is the top banner
echo "<tr><td align=center colspan=2><font size=6><b>WELCOME TO OUR WEB SITE</b></font></td></tr>";
 
// now for the top menu bar
// the menu bar data is controlled by menu management
// the data is accessed via the pageMenuGet function at the beginning of this example
// we take the returned associated array and assign each menu location to it's own array
// we are addressing the top menu here
// see the function pageMenuGet for more details on the data returned
// as we are only touching on what you can do with menus in this example
 
// we will start with a wrapping cell and preceding pipe
echo "<tr><td colspan=2> | ";
// now we loop through each item in the menu and output it
foreach($topMenu as $menuItem) echo "<a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a> | ";
// finally lets close the wrapping cell
echo "</td></tr>";
// note that menu items will not appear here unless they are populated in menu management
 
// lets do the left column now
// the left column contains the left menu, so this will be similar to above
// starting with a wrapping cell
echo "<tr><td valign=top>";
// now we loop through each item in the menu and output it
foreach($leftMenu as $menuItem) echo "<br><a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a>";
// finally lets close the wrapping cell
echo "</td>";
 
// now lets display the center page content
echo "<td valign=top>";
 
// first im going to display the message output
// this is a variable used to pass messages (errors, notifications, etc) from page to page for visitors
// you want this highlighted so it is brought to their attention
// only display this if it has value
if(!empty($attributes['message'])) echo "<font color=red>" . $attributes['message']] . "</font><br><br>";
 
// center page content
// pulled from core variables
// the contents of these variables is controlled via page management
echo "<b>$title</b><br><i>$subTitle</i><br><br>$copy";
 
// now lets close out the center content cell
echo "</td></tr>";
 
// time for the bottom menu
echo "<tr><td colspan=2 align=center> | ";
foreach($bottomMenu as $menuItem) echo " <a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a> | ";
echo "</td></tr>";
 
// close out the outer wrapping table
echo "</table>";
 
// close out the body and html
echo "</body>
</html>";