Posted by david on 30 May 2012 at 12:17 am

I've been a little sick lately, so i haven't focused on as much development as I'd hoped. I have done some work on Clay, but not a lot to ClayCMS. You can see the latest changes on the project's GitHub page.

The biggest changes have been to the templates system. While creating the MT developer theme, I noticed a few bugs from features I hadn't tested in a long while and some ways to improve the template handling. The templates system has always allowed the theme to override application templates, images, stylesheets, and javascript. The way it was before was a little confusing, so I made it more of a drop in solution. Now the theme has it's own templates, images, styles, and scripts folders, but it can also have an applications folder. The applications folder mimics the applications, using the same folder structure. This will hopefully simplify the learning curve for themes and help a developer recognize if an overridden item has changed in the original application.

I expanded the applications' ability to specifiy which templates to use within their class methods (Component Actions). Before it was done by setting the object property $template to a string of the template name:

$this->template = 'toolbar';

would use the template toolbar.tpl in the application's /templates folder.

You can also use subfolders in the template name:

$this->template = 'includes/toolbar';

would use the template toolbar.tpl in the application's /templates/includes folder.

The new addition (you can still use the string for an in-application template), allows you to set the template using an array. This array allows you to specify a template from another application or from a theme:

$this->template = array('application' => 'blog', 'template' => 'toolbar');

$this->template = array('theme' => 'simplestyle_4', 'template' => 'toolbar');

In both cases above it would use the toolbar.tpl template in the /templates folder of whatever the first key is set to.

I also expanded the application object's template method, allowing a 2nd parameter to override the template origin, template name, and override/supplement data provided in template variables.

$this->template($dashboard, array('application' => 'system', 'template' => 'toolbar', 'data' => array('message' => 'This is overridden from the page template'));

The way this works is $dashboard is an array created from using $this->action() on an application object. The 2nd part, another array, adds to or overrides parts of the array provided by $dashboard. The 'data' array defines a variable $message that can be used in the system/templates/toolbar.tpl template. In the example I made it come from a page template, but any template has access to $this->template() and can include other templates. 

I also created a new API to replace the Pager I made a few weeks ago (the one at the bottom of this page). The old Pager used an application object, while new the Pager uses a static application library (class) that is called as an API. It doesn't create any new objects, like the old one did, and seems to be a little more efficient. Application objects aren't resource hogs anyway, but every little optimization helps.

I updated TinyMCE in the Clay repo to the latest version.

Finally, I worked a little on a code highlighter, so I can show highlighted code in blog posts. I may make it into a TinyMCE plugin, but I haven't decided exactly which route to take yet. I am leaning toward a lighter solution than TinyMCE, perhaps something using HTML5. If I move to a different WYSIWYG editor, I will create an option so you can choose which editor to use. I have managed to get a little work done while being sick, but I'm hoping I'll feel better soon so I can focus on something a little more the ClayCMS privilege system, blocks, hooks, etc.


Log in to comment

No comments yet!