Getting Started with Custom Templates (Positions)

These instructions help get you oriented with Seblod custom templates. It offers a full explanation of where your folders and files belong and their purpose in the Seblod template system.

INTRODUCTION

The Seblod templating system is designed to be straightforward and integrate into the existing Joomla template management. Seblod custom templates are simply PHP files placed in the correct folders and named in such a way that they are automatically detected by the Seblod system.

The system allows you to get into deep design work in your site. But first, you have to know where the files and folders belong, and how to name them. That is what these instructions are for.

Before you begin, it is best to first create a content type in the Seblod Form & Content Type Manager with all your fields placed in "positions." These instructions show you how to create a custom template that detects your content type and controls those fields.

LOCATING SEBLOD TEMPLATES

Seblod custom template files must be placed in a folder inside a Seblod template. Seblod ships with some basic templates, which you can use to get started. They are located in the Joomla template folder.

For example, the seb_one template is located here:
.../templates/seb_one/

Inside this folder, there are these sub-folders:
/fields
/images
/includes
/positions
/variations

These instructions concentrate on the "positions" folder. This is where you will place your custom PHP files (templates).

Inside the "positions" folder is the following sub-folder:
/_content_type

Looking a bit deeper, there are four more sub-folders:
/admin
/content
/intro
/site

Finally, inside each of these sub-folders there are two specific files:
index.html
right-a.php

These instructions will use the “right-a.php” file to create your actual template.

If your installation does not have the right-a.php file, you can easily create it yourself. Just follow these steps:
1. Create a blank file with the .php extension

2. Add the following code at the top of the file:
// No Direct Access
defined( '_JEXEC' ) or die;
?>

3. Name the file "right-a.php"

4. Place the file to the same folder described above for the right-a.php file

Once you have created this file and saved it to the correct folder, follow the rest of the steps in these instructions.

PUTTING YOUR TEMPLATE TOGETHER

It might seem like there are a lot of folders, sub-folders, and files. However, in a moment you will begin transforming these in ways that make it very clear what everything is for.

For the purposes of this tutorial, let's assume we have a content type created in the Seblod Form & Content Type Manager called "products." Of course, replace "products" with the actual name of your content type.

Step 1: Create a Template Folder for Your Content Type

Each content type will have its own folder, with a name corresponding directly to the content type. The best way to do this is to copy the “_content_type” folder provided with your Seblod installation.

As described above, here is the full path to this folder:
.../templates/seb_one/positions/_content_type

Step 2: Name the New Folder According to Your Content Type

After copying the “_content_type” folder, name it "products." Now you have this path:
.../templates/seb_one/positions/products

Again, replace "products" with the name of your own content type.  By naming the folder to match the name of your content type, Seblod automatically knows to look for it when you load the forms and content anywhere in your site.

The new “products” folder has these sub-folders:
/admin
/content
/intro
/site

These sub-folders are where you will put all the PHP files that handle specific styling and structure for the “products” content type. Notice that these sub-folders have the same names as the four "views" in the Seblod Form & Content Type Manager.  That's for a good reason: the files you add to these sub-folders is directly linked with those four views.

Here's a summary of each folder's purpose:
admin = the entry form to create articles from the back-end of your site
content = the view for published articles created with this content type
intro = the blog or list view for published articles created with this content type
site = the entry form to create articles from the front-end of your site

Step 3: Create the Actual Template Files for Each View

Inside each of the four sub-folders described in step 2, you will find a “right-a.php” file. This is a "starter" PHP file that you can use to build your new custom template.

Make one copy of the “right-a.php” file for every position you are using in your Seblod content type, and place these files inside each of the sub-folders mentioned above.

For the purposes of this tutorial, let's assume you are using three positions in your Seblod Form & Content Type Manager:
#MAINBODY
#TOPBODY
#BOTTOMBODY

You would make three corresponding copies of the "right-a.php" file, and place them in each of the sub-folders. Rename the files as follows:
mainbody.php
topbody.php
bottombody.php

For custom templates to work, any positions where you placed fields in the Form & Content Type Manager need a corresponding PHP file. Just as Seblod knows to look for a folder named “products,” it also knows to look inside that folder for specific PHP files that match the position names in your content type.

To summarize, here is the new file and folder structure for your “products” content type:

The top-level folder...
.../templates/seb_one/positions/products

Each of the sub-folders...
/admin
index.html
mainbody.php
topbody.php
bottombody.php

/content
index.html
mainbody.php
topbody.php
bottombody.php

/intro
index.html
mainbody.php
topbody.php
bottombody.php

/site
index.html
mainbody.php
topbody.php
bottombody.php

Having a separate PHP file for each position inside each view gives you fine-grained control over the way your fields appear, and how they are structured and styled.

Remember, every "position" you use in the Form & Content Type Manager needs a corresponding PHP file in your "template" folder if you want to have custom structures and styling. If you move fields into new positions, make sure to add a new matching PHP file.

Add Styling and Structure to Your Template Files

These instructions are meant to get you situated with the folder and file structure. The next step is to open each of your template files in a text editor and add references to your specific Seblod fields. You can add DIV elements, tables, CSS classes, JQuery functions, or anything else you would normally do in a PHP file. You can also make references to Joomla plugins and extensions in Seblod custom templates.
For instructions on specific ways to reference fields in custom templates, continue reading related entries in the Templates section of the Seblod documentation.
Schenker
January 14, 2012
2900
March 31, 2012

About Author

Kramer_logo

Matthew

Schenker

United States
Web designer, technical writer/editor.