Planning the Build

How you go about building a theme is largely framed by your intentions for the theme. If you intend to release the theme for the use of others, then it is best to follow certain (albeit largely unwritten) conventions that make the resulting theme more "standard" and therefore, easier for others to use. In contrast, if use by others is not a factor, then you can proceed in a fashion that tailors the code more narrowly to your needs.

For purposes of our discussion in this chapter, I am going to assume you wish others to be able to use your theme and accordingly, our examples will tend toward standardization and increased flexibility without unnecessary complexity; this approach has the added advantage of decreasing your maintenance load going forward, and being more portable.

In terms of features, our goal here is to create a theme with the following attributes:

• Employs PHPTemplate

• Supports one to three columns

• Supports theme configuration options native to PHPTemplate (e.g., logo, search box, site slogan, etc.)

Represented visually, the structure of our page .tpl. php file will be as follows:

page.tpl.php

title (Sheadtitle) metadata (Shead) stylesheets (Sstyles) scripts ($ scripts)

logo (Slogo)

site name ($site_name)

site slogan ($site slogan)

site mission ($mission)

search bo* (Ssearchbox)

primary links (Sprimary links)

secondary links ($secondary_links)

breadcrumb ($breadcrumb)

title (Stitle)

messages ((messages)

regions header (Sheader) sidebar left ($s ¡debarJeft) content {{content) sidebar right (Ssidebar right) footer (Sfooter message) feed icons (Sfeed Jcons) closing tag (Sclosure)

How the functional units will be grouped within the structure of the page.tpl.php file. -[150]-

In terms of the layout that we will impose on the functionality, we will set up a standard three-column layout with a header and a footer, and then create the following structure to hold our functionality:

Header

Sidebar

Content Area

Sidebar

Footer

The general page layout we will define with the CSS for this theme

Regions are the primary key to placement of content and the functionality. By default, PHPTemplate provides for the following Regions:

• Sidebar Right

As discussed in previous chapters, you are not restricted to the default Regions. You can use all or only some of the Regions and you can also define new Regions if you so desire. For the example in this chapter, we will employ all the default Regions. If you are designing themes for others, it is best to include all the default Regions, as the system will show all the default Regions as options in the Block manager, regardless of whether they are present in the page .tpl. php file. Given the system's default display of these Regions in the Block manager, failing to include all the default Regions in your theme may lead to confusion for the site administrator.

Adding new Regions is discussed in Chapter 5.

Now let's put this all together—here's a graphical representation of how our new theme will place the functional elements, including the Regions, relative to the CSS page divisions.

page.tpl.php

title ($head_title) metadata ($head) stylesheets ($styles) scripts ($scripts) <body>

secondary links($secondary_links) Header header ($header) logo ($logo) site name($site_name) site slogan ($site_slogan) site mission ($mission)

search box ($search_box)

primary links($primary_links)

sidebar left ($sidebar_left)

Sidebar

Content Area content ($content) breadcrumb ($breadcrumb) title ($title) tabs ($tabs) help ($help) messages ($messages)

sidebar right ($sidebar_right)

Sidebar

feed icons ($feed_icons) footer ($footer_message) Footer

Diagram of the position of the elements relative to the principal divisions of the CSS layout and the main document divisions. Note that the ordering of the elements within the CSS is done alphabetically here, as the final ordering of the elements will be up to the individual developer.

0 0

Post a comment