Article
eZ publish: PHP's Killer App - Parts 1-3
Sections
Now you may have noticed that I changed a few settings here and there that apply to something called "sections". In fact I eliminated sections completely from the site, because I'm aiming for something simple. Just so you know, sections are a means to produce "multiple versions" of your site, each delivering different functionality, and perhaps a different design. You could use this for anything from simply "skinning" your site for kicks, to something more complicated, such as SitePoint, for example: you might have multiple sections corresponding to SitePoint, WebmasterBase, eCommerceBase, PromotionBase, ServicesBase and SitePointForums.
In general, the trick with designing sections is to look at the other folders under sitedesign directory, and copy the bits you need in order to include the relevant modules in your design. Once you've set your own directories to correspond to different designs, alter site.ini:
Sections=enabled
Then create the sections in the "site manager".
Sections are accessed by placing a number at the end of the URL, corresponding to the section ID shown in "site manager". For example, try the following URLs:
- http://publishdemo.ez.no/article/articleview/1/1/1/
- http://publishdemo.ez.no/article/articleview/1/1/2/
- http://publishdemo.ez.no/article/articleview/1/1/3/
- http://publishdemo.ez.no/article/articleview/1/1/4/
Using the URLTranslator module, you can build easy links to point to particular sections from within the respective frame.php scripts. You'll see exactly how this works when we build a static page.
You'll find more information on sections at http://developer.ez.no/article/articleview/142/1/19/
Hitting the Module
The overall design is now in place. The next step is to apply it to the eZ publish modules you're using, namely eZ article in this example. Before you go any further, though, let's have a quick look at the directory structure of eZ article, examining the directories you need to know about. This will be more or less the same for all other eZ publish modules:
- admin directory: Contains all the code for the back end interface to the eZ article module. If you're interested in modifying the look of the admin interface, below the
admindirectory you'll find atemplatesdirectory with yet another directory calledstandard. The same principle as thesitedesigndirectory applies here. You can create your own directory along side thestandarddirectory, then point eZ publish to it using theAdminTemplateDir:variable insite.iniunder the eZ article section. The other important directory under theadmindirectory iscache, which is used to store pages from the admin interface to the eZ article module. - cache directory: this is used to cache eZ article pages viewed by your site's visitors. As I mentioned, the
PageCachingvariable insite.inican be used to switch this caching on or off. While apply a design, it's best to leave it disabled, then enable it when you're finished. - classes directory: contains all the classes used to make eZ article tick. In general, you won't need to worry about these, although documentation can be found at http://developer.ez.no/doc/view/index.
- user directory: in here you'll find a series of PHP scripts that can be used handle the eZ article module in different ways. These tie the eZ article classes together with the overall eZ publish classes to deliver eZ article pages. You'll see more of this in practice shortly. Below the
userdirectory you'll find atemplatesdirectory, which contains another directory calledstandard-- you'll be making use of this in a moment. Images used within by the templates are found in theuserdirectory inimages/standard. And finally, in theintldirectory are files that allow parts of the page to be displayed in multiple languages -- you'll need this directory when applying your design.
Now that you have an idea of a modules directory structure, it's time to apply that design!
eZ article
As you already now, eZ article is used to create "normal" Web pages. Using eZ article you can publish both "dynamic" articles and "static" pages. Static pages are used for sections such as "About Us" content, which will rarely change and might always be available from a menu. Also, making use of the eZ form module, you can easily attach HTML forms to articles -- another thing I'll be examining shortly.
The first step, though, is to apply the design to eZ article. Open up the directory [ezpublish_root]/ezarticle/user/templates/ and copy the standard directory to phppoint. Do the same with [ezpublish_root]/ezarticle/user/images/standard for good practice, although we won't be changing the images in this article.
Now edit the site.ini to point eZ publish at the new directories:
[eZArticleMain]
AdminTemplateDir=templates/standard/
TemplateDir=templates/phppoint/
ImageDir=/images/phppoint/
While you're there, update this setting as well (also under the eZ article section):
UserSubmitArticles=disabled
On your site, you'll only want administrators to be able to submit articles. So don't forget to clear out the [ezpublish_root]/classes/cache/ directory again as you updated the ini file!
Returning to frame.php for a moment, notice that in building the left hand site menu, there was the code:
<!-- Left menu start -->
<?
$CategoryID = 0;
include( "ezarticle/user/menubox.php" );
?>
This puts a "menu box" from eZ article in frame.php so that it will appear on all pages. Of you open menubox.php from the specified directory, and search the file for ".tpl" you'll find it makes use of a template called menubox.tpl.
In general, there are two ways to access elements of the eZ article module -- via include, or via a URL. Here I've included a script that generates a menu box. You'll see later how to use the URL method when you create a link to a static page. All the available elements are described at http://doc.ez.no/article/archive/55/.
Now head to your [ezpublish_root]/ezarticle/user/templates/phppoint directory and open up the file menubox.tpl. Also, open up the file [ezpublish_root]/ezarticle/user/intl/en_GB/menubox.php.ini.