Over the past two months I have been working on a web site called Get Safe Online with a company called Grasp Digital which I am currently contracted to 3 days a week, it is a government backed web site aimed at making people more a where of the dangers online. For this site I had been asked to use the CMS Expression Engine. Having never used this CMS before I through myself into learning the in’s and out’s.
My first impression was why would one buy a CMS of this nature when there are so many other better solutions out there. Once you get under the hood of this CMS there are some good bit’s and some very frustrating bit’s.
Lets start with the good bits. Firstly if you are looking for a content rich site much like www.bbc.co.uk then expression engine is your CMS, after all Expression Engine claim that the BBC are using there CMS. With the CMS you can quickly get a site up and running displaying articles. For a designer/developer the syntax is very human readable and from what I have seen this is Expression Engines market. As a developer I have found this most frustrating.
This moves me on to the frustrating bits. Expression Engines use of categories is a little convoluted it took me a while to get my head around this and the way it works with the articles. I found a great guy on you tub DaBrook that went through the whole process of creating an Expression Engine site, but he didn’t explain the relationship, he had used a category as if it was just another article. There was no digression into the subject.
With Expression Engine you can have category groups and then multiple categories in that group. You then have to assign the category group to a channel. In the beginning what I misunderstood was when that has been done you can create your articles and assign them to one or more categories. Now in something like WordPress or Joomla this is already done or in fact you only have one category group which is automatically assigned to your articles. At this point I was lost in the wilderness.
After much playing around it twigged. For very big sites you need this for instance with the BBC they would categorize there categories. This is important for the fact that you can have the same category name in multiple category groups.
So that gives us a background into the workings of categories, but I still had a problem with the fact that the site needs to be dynamic. The other frustrating part about Expression Engine is how it handles pages. For Expression Engine to serve a page it needs a template group and this template group can be made up of other template group pages and what is called snippets, pieces of code doing specific tasks kind of like programmable functions.
Most other CMS’s, you create a one template to serve many pages, Expression Engine is almost old skol and backward with it’s template mark-up. There are ways and means which allow for dynamic content in my next post regarding Expression Engine I will explain in more detail.
One last frustrating part of Expression Engine is when using categories to for instance create a navigation menu and a nested one at that, there was no out of the box solution to create one. I thought I am pay for a license for this surly there should be provision for creating a menu using categories. Well there is one but you have no say in how it is created. To create a menu I had to create a custom plugin please see below the plugin.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Menu{
public $return_data = "";
public function __construct(){
$this->EE = &get_instance();
$site_url = $this->EE->config->config['site_url'];
$index_page = $this->EE->config->config["site_index"];
$this->EE->db->where('parent_id',0);
$this->EE->db->where('cat_name !=','News');
$this->EE->db->where('group_id',1);
$this->EE->db->order_by('cat_order');
$segment = $this->EE->TMPL->fetch_param('segment');
$query = $this->EE->db->get('exp_categories');
$this->return_data = "<ul id='mega-menu-tut' class='main-navigation menu'>";
$i=1;
foreach($query->result_array() as $row)
{
if(preg_match('/&/',$row['cat_name'])){
$start = 1;
$title = '';
}else{
$start = 0;
$title = '';
}
$titleOld = explode(' ',$row['cat_name']);
for($i=0;$i<sizeof($titleOld);$i++){
if($i==$start){
$title .= $titleOld[$i]."<br class='iphone' />";
}else{
$title .= $titleOld[$i]." ";
}
}
$path =$site_url.$index_page.'/'.$row["cat_url_title"];
if($segment == $row["cat_url_title"]){
$this->return_data .='<li class="menu-0'.$i.'"><a href="'.$path.'" class="current">'.$title.'</a>';
}else{
$this->return_data .= '<li class="menu-0'.$i.'"><a href="'.$path.'">'.$title.'</a>';
}
$this->EE->db->where('parent_id',$row['cat_id']);
$this->EE->db->where('cat_name !=','News');
$this->EE->db->where('group_id',1);
$this->EE->db->order_by('cat_order');
$query1 = $this->EE->db->get('exp_categories');
if(is_object($query1)){
$this->return_data .= "<ul>";
foreach($query1->result_array() as $child)
{
$path =$site_url.$index_page.'/'.$row["cat_url_title"].'/'.$child['cat_url_title'].'/';
$this->return_data .= '<li ><a href="'.$path.'">'.$child['cat_name'].'</a>';
$this->EE->db->where('parent_id',$child['cat_id']);
$this->EE->db->where('cat_name !=','News');
$this->EE->db->where('group_id',1);
$this->EE->db->order_by('cat_order');
$query2 = $this->EE->db->get('exp_categories');
if(is_object($query2)){
$this->return_data .= "<ul>";
foreach($query2->result_array() as $sub_child)
{
$path =$site_url.$index_page.'/'.$row["cat_url_title"].'/'.$child['cat_url_title'].'/'.$sub_child['cat_url_title'].'/';
$this->return_data .= '<li ><a href="'.$path.'">'.$sub_child['cat_name'].'</a>';
}
$this->return_data .= "</ul>";
}
$this->return_data .= "</li>";
}
$this->return_data .= "</ul>";
}
$this->return_data .= "</li>";
$i++;
}
$this->return_data .= "</ul>";
}
}
?>
Calling this plugin is really quite easy in the template group you write {exp:menu segment=”{segment_1}”} the segment parameter was for checking if the user was on segment one and if so add a class to the anchor link to make it sticky i.e give it a colour.









