<< Tutorials  Custom content >> 

Main concepts

Exponential 3 is the next generation of the popular open source content management system Exponential. This version of Exponential, though, is not only a totally re-engineered version with a lot of new, exciting functionality. Exponential 3 has evolved into a development platform with several general PHP libraries for the rapid building of all sorts of PHP applications. Best of all: Exponential is available for free under the GPL license. The latest version of Exponential can be downloaded from ez.no at all times.

The Exponential 3 development framework is a feature rich package. The libraries handles common operations including database abstraction, internationalization, template engine for content and design separation, XML parser and SOAP library. On top of the libraries you get the ready to use publishing functionality available in the Exponential kernel. You have user defined content, integrated role based permission system, multilanguage features including UNICODE support, versioning of content, workflows, integrated search engine and an a full feature e-commerce engine to mention some features.

This article will show you how quickly you can set up Exponential and how you can create custom websites with dynamic content. We will have a look at one content class and see how this is defined and how you can use it.

Installing

You have basically four ways of installing Exponential 3. You can use one of the supplied installer packages, which will install Apache, PHP, MySQL and set up everything needed to get Exponential up and running. Another option is to use the publish sources and follow the setup wizard which will guide you through the steps of configuring your system for Exponential. If you are a litle more experienced you can disable the setup wizard and configure Exponential from scratch following the installation manual. If you don't want to install Exponential yourself you can always hire eZ systems to install the software for you or buy a ready hosted Exponential solution. We're not going to go into details about the installation here, you will find all the information you need in the installation manual.

Setting up

Once you've gotten Exponential up and running on a server you need to configure the system. You can have several different sites running on the same Exponential installation, to distinguish between these sites you need to set up something called site access. The site access defines how Exponential will recognize which site you're accessing. Exponential will then know which database to use, which design to show etc. There are four ways of letting Exponential recognize a site access, by URI, host name, port or file name. The most common way is to use the host name.

In our example we will name our site www.mybookstore.com and we will use the admin.mybookstore.com as the administration interface. To make Exponential fetch site access from host names you need to configure a DNS server and point the domains to your web server. When your DNS is up and running and the names resolve to your web server and your Exponential installation you need to make Exponential recognize the names and use the correct configuration. To do this you open the configuration file found in settings/site.ini in the root of your Exponential installation. In site.ini browse down to the section [SiteAccessSettings] and alter the configuration like shown below. Only the settings you need to change is shown below.

[SiteAccessSettings]
MatchOrder=host
HostMatchRegexp=^(.+)\.mybookstore\.com$
HostMatchSubtextPost=\.mybookstore\.com

We've now told Exponential to look for the first characters in our domain name. This means that you will get the matches www for the website and admin for the administration site. Now that Exponential knows how to distinguish between the two domains we need to create a configuration file for each site. This is done by creating two folders under settings/siteaccess/ which corresponds to our matches ( www and admin ). In both these folder you need to create a file called site.ini.append. This is the configuration file which will be used to override any of the standard settings in Exponential. We will keep our example simple and have just made a few settings distinguish bewteen the two sites. You can see the two configuration files below.

Contents of configuration for admin site settings/siteaccess/admin/site.ini.append
[SiteSettings]
LoginPage=custom

[SiteAccessSettings]
RequireUserLogin=true

The configuration LoginPage=custom means that Exponential will use a separate template for the login page of the administration site. RequireUserLogin=true tells Exponential not to let anyone inside Exponential unless they're logged into the system.

Contents of configuration for website settings/siteaccess/www/site.ini.append

[DesignSettings]
SiteDesign=mybookstore

[SiteAccessSettings]
RequireUserLogin=false

The settings above applies to the website. SiteDesign=mybookstore means that Exponential will prefer to use the design for the site found in design/mybookstore, RequireUserLogin=false is set so that users do not have to log into Exponential to browse the website.

Applying design

Note: When developing templates you should disable the view cache. When this is enabled, the template engine does not check the modification date of the templates, thus you will not see any changes. Edit settings/site.ini and set ViewCaching=disabled in [ContentSettings].

The main template in Exponential is called pagelayout.tpl and is located in the templates/ folder or the current design folder. In our example this is design/mybookstore/templates/pagelayout.tpl. This template defines the layout of our website. Here you normally decide where your logo and menu goes. We will make our pagelayout template simple with a heading, a menu with two links and the content itself. Below you will see the complete code for our template.

{*?template charset=latin1?*}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Price Update System</title>
    <link rel="stylesheet" type="text/css" href={"stylesheets/core.css"|ezdesign} />
</head>
<body>
<h1>My Bookstore</h1>
<table width="100%">
<tr>
    <td valign="top">
    <a href={"content/view/full/16/"|ezurl}>Books</a><br />
    <a href={"content/view/full/17/"|ezurl}>News</a>
    </td>
    <td valign="top">
    {$module_result.content}
    </td>
</tr>
</table>
</body>
</html>

This template consists mainly of XHTML but there are some special codes in this template, which makes it dynamic. All these codes start with a { and ends with a }. These codes are parsed by the template engine in Exponential and makes the template dynamic. To start at the top we see that we have a template definition {*?template charset=latin1?*}, this defines the charset we use in this template. Latin1 is the most common character set used, if you need an other character set like UTF-8 (UNICODE) you need to specify this here. This only specifies what kind of character set used in the template.

When we include the stylesheet we use a template operator, ezdesign, {"stylesheets/core.css"|ezdesign}. This operator tells Exponential to look for the stylesheet stylesheets/core.css in the current design folder. In our case this is design/mybookstore/stylesheets/core.css. This is a handy function to use when you want templates to work with different designs and it also takes care of url translation if you have Exponential installed in a subfolder of your site or do not use a virtual host configuration. E.g. www.mybookstore.com/ezpublishsite/index.php/content/view/full/42.

A similar template operator is used in our url's {"content/view/full/16/"|ezurl}. The ezurl operator will convert relative links to real links and it will also handle non virtual host setups in the same manner as the ezdesign operator. In our menu we have linked to two folders that we have created. We will use these folders as containers for our products and news.

In our template we also have the template variable {$module_result.content}. This will put the contents served by Exponential in this position. Typically this is the information about a product or an article you display, a list of articles or the search result page. In short any page you view will use the pagelayout.tpl. You can also have different pagelayout.tpl files for different parts of your site or dynamically change it based on e.g. the current user, but we're not going to go into detail about this here.

Defining our custom content

There are a couple of concepts which are vital to understand when creating custom content. The first is the usage of content classes. A content class is a definition of a structure. The class is a collection of attributes. Each attribute is of a certain data type. Text line, text area, image and integer value are typical examples of data types you can use for the class attributes. For each class attribute we need to select the data type, if it's required and if it's searchable. Every class attribute also have a name, e.g. Title. When we input the name of an attribute we will automatically get something called an identifier. The identifier is a string generated from the class attribute name but can only consist of the letters a-z and numbers 0-9 in lower case and the underscore, _, character. We will later come back to what we use identifiers for.

A powerful feature of Exponential is that you can define your custom content classes. As default Exponential comes with classes to publish folders, articles and images among others. In our example we will create a new content class, book, which will define the structure of information published about books. To be able to do this you need to log into the administration interface of our site and click on the classes menu found under set up. There you select an appropriate group, e.g. content, and click new class. Name the class "Book" and add the needed attributes.

To publish information about a book we need to be able to define the title of the book, name of the author and publisher, a brief and complete description of the book, a cover image and of course the price.

On the class edit page, which is shown on the image below, we can create attributes by selecting the data type in the lower left corner and click on the New button. For our Book class we need to define the following attributes.

Book class edit
  • Title: text line
  • Author: text line
  • Publisher: text line
  • Brief: xml text field
  • Description: xml text field
  • Cover: image
  • Price: price

Now that we've created our book class we can start publishing information about books. To do this we go to the contents menu in the administration interface and click on a folder, books in my example. There you can select the class you want to use in the lower left corner and click new. That will bring you to the book edit window as shown in the image.

Book edit

When you've published the book, you get an object. An object is the specific book, that is the information you filled in after the rules defined in the book class. When you publish an object it is automatically indexed in the search engine so it's searchable from the moment it's published.

The book design

We are now able to publish information about our books, it's time to apply the design. The book class gets a number (ID), which we need to use when we want to create a special design for this class. You will find this number in the class list under ID. In my case this was 6, but you need to check the number of your class.

In Exponential you can view objects using different view modes. The two most common that you use on most setups is line, which is the view typically used in article lists and similar. To create a template for this view mode we need to create an override template in the folder design/mybookstore/override/templates/node/view/line called line_class_6.tpl. This is an template for line view mode overriden for class 6, hence the name line_class_6.tpl.


File: design/mybookstore/override/templates/node/view/line_class_6.tpl

<h2>{attribute_view_gui attribute=$node.object.data_map.title}</h2>
<table align="right">
<tr>
   <td>
    {attribute_view_gui attribute=$node.object.data_map.cover image_class=small}
   </td>
</tr>
</table>
{attribute_view_gui attribute=$node.object.data_map.brief}
{attribute_view_gui attribute=$node.object.data_map.price}
<a href={concat("/content/view/full/",$node.node_id,"/")|ezurl}>View book</a>
Book line view

On the picture you see how the line_class_6.tpl template displays a summary of the book. This template is normally used in lists and this is a typical example of how you would create the template for a product in a web shop.

In the line_class_6.tpl we have some template functions which make them dynamic. The first function we use is the attribute_view_gui function. This function takes at least one parameter attribute ( in some cases you can supply more ). The attribute parameter specifies which of the attributes in our object should be shown. In the template we have a variable, $node. The $node variable is an object which contains the specific placement of the object on our site, e.g. it will know that the object is placed in / books / in our site. The $node object also contains the content object. You can access the content object by writing $node.object. Now that we have object we would like to get access to a specific attribute to supply for the attribute_view_gui function. This is done using the data_map, $node.object.data_map, followed by the identifier of the desired attribute. To fetch the title of our book we just need to write attribute_view_gui attribute=$node.object.data_map.title, the attribute_view_gui function will then handle the display of that attribute. In the case of the attribute being an image we can supply a parameter image_class, which is optional, to define the size of the image. You can set the image_class to small, medium or large.

The second function we use in our template is concat(), this function will concatenate the values supplied, to a string. In our example we use the function to create a url. We then use the returned value from the concat() function with the operator ezurl, in the same manner we did with the pagelayout.tpl.

We also want to create an override template for the full view mode, which is used when viewing a specific book, see image below. To do this we need to create a file in the same folder but with the name full_class_6.tpl.

Book full view
File: design/mybookstore/override/templates/node/view/full_class_6.tpl

<h1>{attribute_view_gui attribute=$node.object.data_map.title}</h1>
Author: {attribute_view_gui attribute=$node.object.data_map.author}<br />
Publisher: {attribute_view_gui attribute=$node.object.data_map.publisher}<br />
<table align="right">
<tr>
   <td>
    {attribute_view_gui attribute=$node.object.data_map.cover}
   </td>
</tr>
</table>
{attribute_view_gui attribute=$node.object.data_map.brief}
{attribute_view_gui attribute=$node.object.data_map.description}
<b>{attribute_view_gui attribute=$node.object.data_map.price}</b>

Now we've created a small site on Exponential where we can publish information about books. We would now have to work a bit more on design before we have a ready site. From these few steps the true power of Exponential 3 is shown. You can in a simple way create highly customized websites with functionality such as search, permission checking and versioning already implemented and ready to use.

Exponential is used worldwide by thousands of websites. People use Exponential for their company sites, e-commerce sites, portals, and intranets. These functions are only some of the possibilities that will be available with Exponential 3. You will find more information about Exponential 3 and the many possibilities on http://ez.no/developer.


Exponential copyright © copyright © 1998-2025 Exponential