Wiccle.com in Facebook Wiccle.com in Twitter Wiccle.com in LinkedIn Wiccle.com in Youtube RSS from Wiccle.com Wiccle.com in Atom
 
 
 

Thread: Tutorial: Creating data preprocessors for static content

Started: February 25, 2010, 08:44 AM  ⋅  Zone: Public Forums  ⋅  Category: Install & Modification  ⋅  Posts: 1  ⋅  Views 526
Started by: Markus  ⋅  Description: iWiccle has a large number of useful features you can employ in creating create your custom content and web pages --- great time-savers and productivi...
Post #1
Member: Markus  ⋅  Date: February 25, 2010, 08:44 AM  ⋅ Subject: "Tutorial: Creating data preprocessors for static content"

iWiccle has a number of useful features you can employ in creating custom content and pages for your site. This tutorial discusses unit data preprocessing. If you don't know what a unit (or a box) means in the context of Wiccle CMS software, please read the builder tutorial first.

---

Content Units and Static Preprocessors

Units are the lowest level of content in the Wiccle CMS hierarchy. They are the final building blocks inside which all your content, whether static or dynamic, is placed. As with dynamic processors, you can intercept the unit data before and after the system has parsed it. The declarations for unit parser and pre-parser are as follows:

$core['module']['unit_parser'] = "unit_parser";
$core['module']['unit_pre_parser'] = "unit_pre_parser";

A unit parser can modify any of the fields coming in from the unit database table, as well as add in new fields as desired. If your unit is dynamic, the unit_parser ("postprocessor") will receive the ready-parsed HTML under unit_content after it has passed through the templating system.

Depending on your objective, a pre-parser or a post-parser may fit the bill better. If you want to for example run a search-replace on your custom content only, you should go with a "unit_pre_parser". If you want your processing to effect the ready-parsed unit including the unit base you have selected, "unit_parser" is the way to go.

 

Examples of Unit Processor / Parser Usage

There are countless possible uses for these features, from the simplest operations (some of which are illustrated in the dynamic processor tutorial) to more advanced options.

In the dynamic tutorial, we didn't touch on conditionals. You could for example have your unit_parser say:

if (substr($unit['unit_parent_ident'], 0, 8) == "special_")
{
     $unit['unit_custom_content'] = "<h3>Special!!</h3>".$unit['unit_custom_content'];
}

This would add a header saying "special" to all units on any page with a URL having the string "show=special_". If you wanted this only for units of a particular kind, you could add in a conditional clause like if ($unit['unit_type'] == "post"), in which case it would only apply to post-type content.

A more advanced and creative application is in action at the Forster Court Hotel website. In this case, we wanted to create a slideshow without using flash, and also to make the amount, order and names of the slide images configurable directly from within the builder.

FCH Unit Parameters

In this case, I entered a comma-separated list of images in the desired order under a "slides=" variable under Parameters. Then, I created a unit_parser that exploded() the new $unit['slides'] variable into an array, which was then looped over to produce the javascript that was sent onward as $unit['slide_codesnip'], and became available as [[SLIDE_CODESNIP]] in a custom unit template to create the slideshow.

In this case, the processor takes the list, parses it into 1) the javascript doing the looping, 2) the stacked image tags, and (in the original version) 3) into a row of additional links for navigating between the slides. The total code for accomplishing the above is in the range of 80 lines, HTML and javascript included. (I will recycle this into an iWiccle/Wiccle built-in feature when I get a moment to trim it to a generic add-on.)

 

Hook it up and extend your creativity with ease!

Taking advantage of the built-in processor hooks in iWiccle and Wiccle lets you extend your website functionality beyond your wildest imagination in a relatively simple and quick fashion. A bit of creative thinking and a couple of lines of code can invoke every flavor of funky solution from the depths of the system.

I built a great deal of the system specifically to accommodate the needs of web developers and website designers, who need to do stuff like this all day long, and would rather get it done fast, and also give their customers a way to have simple means for managing their content. I don't care to spend hours on end myself in providing solutions like this from a scratch and without a slick supporting framework, and with that in mind these tools were designed for hands-on application and maximum productivity with minimum effort. Please take advantage of what's available and bring your productions to a whole new level.

 

Install & Modification

Add to Favorites
Public Forums
Category  ⋅  Deploying iWiccle and Wiccle into unique solutions that match your needs.
 

Public Forums

Add to Favorites
Public Forums
Zone  ⋅ Public forum sections for support and discussions. Available for everyone.
 

Zone Categories

 
Questions? Ask us!
Back to Top