Zencart Plugin Framework – Day 5 – Introducing the template blocks/holders

With ZePLUF, I wanted to solve ONE issue that has been bugging me for years working with Zencart: the template editing issue.

Thinking back to the last time you installed a module that adds some new element(s) on your site, think of the process of doing it (in fact, just open that plugin’s README file):

  1. Edit the file includes/templates/YOUR_TEMPLATE/templates/tpl_product_info.php
  2. Find this line “blah blah blah”
  3. Add right about it the code below: “blah blah some code you may don’t event understand”

What is wrong with? Well, many. Think of this:

  1. 3 months later, you now do not want to use that plugin anymore and want to remove it, can you remember which files you edited to install it?
  2. You want to temporarily disable this plugin, but oh no you find out this plugin has no on/off switch, you will have to go to the exact template file(s) to remove it
  3. You want to move this plugin (the newsletter box) for example, to another place, what do you do?

Eventually, installing and removing plugins on your site will leave you with lots of garbage and useless files and such.

ZePLUF introduces the idea of template blocks, or we’d like to call it “holders” . It’s not a brand new idea never been done before, but it’s the first time something like it is introduced into Zencart, and it’s sexy. The “holders” in ZePLUF let you put PLAIN and SIMPLE HTML comments into your template, and the plugins can be hooked into this holders to generate views.

More on that will be covered soon, but for now, enjoy this sexy code:

Read More →

Updates 6/27/2012

Today we want to announce some super cool news for the developers of Zencart, it’s exciting for us to announce several updates:

1. The Zencart Plugin Framework will now support frontend controller as well. It means that as a developer now you can add new “pages” into the zencart site without going through the usual hassles. More on this later in a separate post.

2. Our CSS Javascript loader now supports adding library on the fly, this will give the devs a way to use the libs that are not included by default on the CJLoader package. Again, more on this later in a separate post

3. Last but not least, as you can see we are still working on our site. A store will soon be added to the site which will features many Free and Commercial modules we have been working on for Zencart.

Read More →

Zencart Plugin Framework – Day 4 – Working with templates

Working with Zencart templates can be a real pain for store owners and even developers; especially when you install plugin that needs to display something on the store. Usually you will have to edit a template file, put a line of code to pull that plugin’s template file. What happens when you decide that you don’t want to use that plugin anymore and want to remove it? It’s not an easy task either, you will have to track down all the files you made changes to revert them back to previous stage, which can be years ago (and sometimes it’s not even you who installed the plugin in the first place, which further complicates things).

In our years of working with Zencart, we have seen so many people struggled to install a simple plugin. All Zencart store owners seem to have to take a crash course in PHP, HTML and Zencart structure in general. But do they have to? Is it really necessary for them to do so? The answer, in our opinion, is a big NO. What’s so beautiful about WordPress is that almost 99% of its plugins are just plug-and-play, so simple, so straight forward, so effort less. It’s not very do-able with the current Zencart’s structure which is lacking lots of “hooks” for 3rd party modules to plugin in, but we try to make that happens, at least within the template.

Our Zencart Plugin Framework(ZePLUF) was designed with the end users in mind, and by end users we do mean real store owners with zero to nil PHP or Zencart’s internal structure knowledge. ZePLUF introduces what has been the norm in most modern framework: the “hooks” inside. the views (templates). In ZePLUF, these are called “holders” because they are basically place holders which can be input with any display text. A carefully thought out and coded template should already contain all these place holders in the appropriate position which the store owners when installing a new module can decide to use those pre-placed “holders” to render a certain view from the plugin. Obviously, the store owner can also easily place a new “holder” if he or she wants.
There are 2 ways to place a holder into a template file:

Option 1 (PHP code)

echo $riview->get('holder')->get('slot_name');

Slot name can be any thing you want, but it will act as a unique identifier for the plugins and other codes to input the content into it

Option 2 (HTML code)

Alternatively, it’s also possible to simply put a simple HTML code as shown above and let ZePLUF parse it for you. You will have to change the configuration of riCore to turn the “parse_holders” to true, however.

Read More →

Zencart Plugin Framework – Day 3 – Understanding plugin’s structure

Today is a special day for the devs, I will explain the structure of a standard ZePLUF plugin so you can easily develop your own plugin. You will find how easy and quick it is to create anything you need with this new framework.

If possible, all plugin files should be placed under plugins/yourPluginName to avoid conflicts with other plugins and to keep things organized. Please make sure that you name your plugin folder using the camelCase format.

Below, you will find the list of possible folders and files in a standard plugin:

|– config all the configs of the plugin should be here
|– lib all the logic code of the plugin should stay here
|—- classloader.ini this file is optional and will be explained later
|– content
|—- resources this is where all the images/css/js files stay
|—- views this is where all the template files stay
|– vendor if the plugins use 3rd party scripts, they all can be placed here
|– pluginName.php this file is optional and will be explained later
|– plugin.xml
|– translations this folder should contain all the language files


All the configuration files should be stored in this folder.

  1. All .php files will be automatically loaded in alphabet order. Note that all these files are loaded inside a class, so if you want any variables to be accessed globally, you need to declare
  2. settings.yaml: if the plugin contains this file, its content will be loaded and parsed automatically (given that the plugin is enabled). The content in here can then be accessed via the settings instance:

    I will have a special post to cover this because there are many more tricks you can do with it

  3. services.xml: if the plugin contains this file, it will be used to register service to the service container. If this file does not exist, then ZePLUF will automatically register all .php files inside the lib folder to the service container using the default settings (so all services will be registered as containers, not prototypes)
    This file is also quite important if you want to extend or override a plugin’s class as you can simply make changes to the class path inside this file (I’m not going to cover in details how Symfony’s service container works here as already does a pretty good job of that)
Tip: if your plugin has some extra functions you need to use globally, you can create a functions.php file for example (the name is not important) and put your functions inside this file. 


This folder should contain all the logic files of the plugin which include models/controllers and whatever logic code you should need. We do recommend that you namespace all your classes/functions and such so that you can avoid conflicts with other plugins and with Zencart’s core.

One thing to note is that all the files inside this folder are not loaded by default, they are loaded on demand using ZenMagick’s classloader. By default, your namespace must follow your directory structure, so for example if your plugin’s name is myPlugin then within this lib folder you must use the namespace


Luckily, if you are like me, and you don’t like having long namespaces, you can easily cut short by creating a file named classloader.ini inside this lib folder and define all your namespaces here (view the above link for some examples)

If you use subfolders here, your namespaces must follow the directory structure or you MUST also define them in classloader.ini.


Basically all templates and resources files should here. Since there are lots of things going in this folder regarding the template rendering, resources loading and overriding I will cover it in a separate post.


If you use 3rd party developed packages you should place them all here. You can also have a classloader.php in this folder to define your namespace(s).


This file, if exists, will be automatically loaded. This file is also expected to have a method named init which does not take any parameter and will be called once the plugin is first loaded.

If you need to use Zencart’s auto loader, you can define it within this method, there is no need to put a file into includes/auto_loaders/ which will just create another garbage file for users later once they want to remove the plugin. Another nice thing is that this is loaded only when the the plugin is enabled.
Below is an example take from one of our plugins:

// if we want to load this on frontend only
// note that this file is loaded within our class method, so you HAVE TO define $autoLoadConfig as global var
global $autoLoadConfig;
// see how you can also put the observers inside your plugin folder
$autoLoadConfig[200][] = array('autoType' => 'include', 'loadFile' => __DIR__ . '/lib/observers.php');;


This file contains the plugin’s information such as: developer(s), version, release date, update url, dependencies, changelog and such…


ZePLUF use gettext to translate text for several reasons:

  1. Very easy to use, big time saver
  2. Readily available editors such as poedit
  3. Less error prone compared to Zencart’s php constants

There will be a post on our blog that cover this in much more details, stay tuned.

Read More →

Zencart Plugin Framework – Day 2 – Configuration and Plugin Installation

On day 1, I have introduced to your our new Zencart Plugin Framework, what you will get from it and how to install it, today I will cover the configuration of the framework and how to install plugins written for it. Boy, this will be a short day because installation of plugins using ZePLUF will be so simple.


Right now, the only configuration file you should be worried about is settings.yaml, this file already has the notes for each configuration but I will explain them in more details here (YAML is a user friendly configuration file. Unlike PHP or XML, YAML is actually readable and understandable for users who have no programming background. Note that you never use “tab” in a YAML file, always use “spaces” instead. Read more about YAML here)

  preload: [riCore, riSsu, riCache, riCart, riUtility, riLog, riSession]

Unlike Zencart’s default framework which does not have the concept of “plugins” and so doesn’t allow you turn plugin on or off easily, with ZePLUF you can easily turn on/off plugins any time you like. The global config here will tell ZePLUF to load these plugins on both front and back ends in the order specified.

  preload: [riOrder, riCustomer, riZCAdmin, riCsv, riInventoryReport]

the list of plugins to load on backend only, in the order specified.

  preload: [riFilter]

the list of plugins to load on frontend only, in the order specified.

  translator: { fallback: en }

you only need this if you use multiple languages

Plugin Installation

Installing a plugin that was CODED FOR ZePLUF is quite easy, if the plugin was coded to our standard then you will simply have to copy it to the plugins folder and then you may need to edit the settings.yaml above to turn it on and that’s it.
For some plugins, you may need to edit some Zencart files (this is the limitation of Zencart itself)

Today, I will show how to install one of our famous plugins: Simple Seo Url which does have a version coded for Zencart so you can have an idea:

  1. Download the module from github, make sure you get the ZePLUF branch
  2. Put the files and folders you downloaded into plugins\riSsu
  3. Simply edit 1 file as instructed in the readme
  4. Goto admin – extras – Plugin Manager to install and activate SSU
  5. Done

Read More →

WordPress on the go

Wordpress on the go
The reason why WordPress has become so popular is that it has:

  1. Intuitive UI
  2. Huge number of themes and plugins, both free and commercial
  3. Superb support on multiple platforms

For those who are using WordPress or plan to use it, note that you now can easily your WordPress site easily on your smartphone with WordPress’s free mobile apps:

Read More →

Zencart Plugin Framework – Day 1 – Installation

Today I’m gonna post the first post of a series of posts on our newly released Zencart Plugin Framework (ZePLUF) which has been built to make working with Zencart much easier.

After working for years with Zencart, we have felt that even though it’s a great shopping cart, it has many limits:

  1. Plugins: the way it is now, installing a plugin usually involves copying the plugin files into many different places in the cart, it’s complicated and error-prone. Another issue is that when you later remove the ones you don’t need, it’s very easy to leave some thing behind not noticed.
  2. Translation: Zencart is using php “defines” to allow the creation of multi language sites. The issue is that this method is tedious for developers, and very error-prone for normal users.
  3. Templating: Zencart’s current template system doesn’t allow us to easily “inject” a piece of code into it. To put it simply in plain English, if I have a plugin which will display the top 10 products on my homepage, I will have to edit the homepage framework and put some code in. Later, if I decide to remove the plugin, I obviously have to edit the files again to remove the code. This complicates things and makes working with Zencart much more difficult than it should be.

The Zencart Plugin Framework is developed to solve all those above issues and more. So now with that in mind, if you are interested in it, lets get started with the installation process which is not that complicated.


You will need PHP 5.3 or newer to be able to use ZePLUF. The reason is that this plugin makes use of a bunch of Symfony 2.0 bundles which require PHP 5.3 or newer to work.


The plugin is put on GitHub at:

There are 2 ways to install it: you can either clone the git* repo (which allows you to use the latest code) if you are familiar with Git, or you can visit the download section to grab a package.
* Note that if you go for the git option, you will have to get all the sub modules as well. You can do “php install/vendors.php” via the git bash console to pull all these modules. Make sure that you get EVERY submodule, sometimes for some reason 1 or 2 module may not be dowloaded.

Step 1

Create a folder named “plugins” in your Zencart’s root folder. This “plugins” folder should be on the SAME level with your admin and includes folders.

The whole ZePLUF folders/files should be placed inside this plugins folder.

Step 2

You will find inside the ZePLUF package you downloaded, there is a folder named install, inside this folder you should find:

  1. zencart/includes folder: all files/folders inside this folder should be moved to your Zencart’s includes folder which should be right at the root of your Zencart.
  2. zencart/your_admin_folder folder: all files/folders inside this folder should be moved to your Zencart’s admin folder.
  3. zencart/index.php file: this file should be moved (and overwrite) your current Zencart’s index.php. If you have edited your index.php file before for some other purposes, you may need merge the 2 files using a software such as BeyondCompare or WinMerge.
  4. zencart/ri.php file: this file should be moved to your current Zencart’s root.

And that’s it, the installation should be completed now. If you run into errors such as “blank page error” you may want to turn on the debug and see what’s happening.

If you want us to do it for you, we also offer commercial installation service which we will post a link here soon.

That’s it for today and on day 2 we will learn how to install plugins with this framework and how to use some of its basic features.

Read More →

Get categories ordered by meta key on WordPress

For our website, we are using WordPress (we used to use Zencart before, but now we switched to WordPress and will only use Zencart for the store section). So for our own purpose we installed a WordPress plugin called Category Custom Fields which can add unlimited custom fields to any cateogry/taxonomy.

The problem with the plugin though, was that there was no way we could order the categories by those extra custom fields (this is true as of the date this article is written).


This was supposed to work, but it did not. I searched high and low without a solution, then finally after reading lots of articles and checking the code I found out that this can be done using WordPress “hooks” without hacking into the core code:

Simply put the code below into your theme’s functions.php file:

function category_custom_field_get_terms_orderby( $orderby, $args ){
    if($args['orderby'] == 'category_custom_field' && isset($args['category_custom_field']))
        return 'cv.field_value';
    return $orderby;

function category_custom_field_get_terms_fields( $selects, $args ){
    if($args['orderby'] == 'category_custom_field' && isset($args['category_custom_field']))
        $selects[] = 'cv.*';
    return $selects;

function category_custom_field_terms_clauses($pieces, $taxonomies, $args){
    global $wpdb;
    if($args['orderby'] == 'category_custom_field' && isset($args['category_custom_field']))
        $pieces['join'] .= " LEFT JOIN $wpdb->prefix" . "ccf_Value cv ON cv.term_id = tt.term_id AND cv.field_name = '".$args['category_custom_field']."'";
    return $pieces;

add_filter('get_terms_orderby', 'category_custom_field_get_terms_orderby',1,2);

add_filter('get_terms_fields', 'category_custom_field_get_terms_fields',1,2);

add_filter('terms_clauses', 'category_custom_field_terms_clauses',1,3);

And now you can get the categories in the order you want using:


I have posted this question on stackoverflow as well (and ended up answering my own question)

Read More →


Taming The Wild Mind

Myths have developed around and researchers have studied how the human brain juggles creativity and organization. Popular theory tells us that the left brain is structured and logical, while the right brain is artistic and imaginative, and that all human beings use predominantly one side of the other.

Working in a creative field means challenging that theory, or else challenging the schedules and deadlines that managers impose on writers, designers and other creatives. As a project manager in a UX design agency, as well as a writer, I believe it is necessary to challenge both the assumptions about schedules and the belief that creativity implies disorganization.

Can Creativity Be Scheduled?

There’s a quick and easy answer to this question. Yes!

You’re shaking your head now. You’re thinking about how much you hate deadlines and how your designs suffer from the 9:00 to 5:00 schedule imposed by your manager. You’re remembering the sketches or creative writing you did in college at 3:00 in the morning. Sathish Manohar expresses it well in his article “Why 9 to 5”:

“Knowledge work solely depends on creativity of the workers. But, still some how, knowledge work-places got modeled around factories. Employees had to work 9-5, be creative between 9-5, and go home… This is a problem, We cannot schedule the brain to be creative at any given time.”

Yet I’ve spent years trying to merge my creative-writing personality with my project-management skill set and day job. Recently I realized that writing by the light of the moon results in over-caffeinated mornings and sloppy grammar, and still I continued—after all, isn’t that what creativity is all about? I’ve always been able to empathize with my designers, who want nothing more than free reign to be creative when the mood hits. But as a project manager, I also strive to create a working environment where designers and content strategists can be productive and efficient—and where we can deliver mockups on a deadline.

The solution turned out to be easier than you might expect. Spontaneous creativity is not the only way. In fact, as a content strategist, designer or even developer, you are paid for your ability to turn on the creative faucet. So, what goes into creating on command?

1. Create A Routine

“Be regular and orderly in your life so that you may be violent and original in your work.”

– Gustave Flaubert, author

Flaubert did not write on a deadline, and yet he found that following an orderly routine improved his ability to be creative. This holds true for most people. Being able to “do your best work” at 3:00 am is no coincidence: you are training your brain to get those creative juices flowing when the moon is high and the workday is long over. This is fantastic if you don’t have anywhere to be in the morning; but for many of us, 3:00 am is not a great time to be inspired.

Instead, develop a routine that trains your creative juices to kick in at more convenient times. This could mean setting the alarm for 8:00 am, making breakfast and then sitting down with a journal to begin sketching as you eat. It could mean emailing yourself a to-do list before bed, with inspirational quotes to greet you the moment you open your email. Maybe you need a lunchtime scrum every day to energize and focus. Within two weeks, these mini-kickoffs will begin to signal to your brain, “Now is when we begin the creative work of the day.”

2. Take Your Time

“A single meeting can blow a whole afternoon, by breaking it into two pieces each too small to do anything.”

– Paul Graham, essayist and programmer

Distractions are a powerful creativity-blocker. Even the best routine can be waylaid by mandatory meetings, important phone calls and constant emails. If you are a freelancer in charge of your own schedule, try to relegate meetings to the very beginning or end of the day. If a manager schedules your client meetings and internal reviews, talk to them about the benefits of opening up large blocks of time for creative work.

At Above the Fold, we make a point of scheduling around the “maker’s schedule.” Paul Graham sums up the maker’s schedule in his essay, “Maker’s Schedule, Manager’s Schedule”:

“When you’re operating on the maker’s schedule, meetings are a disaster. A single meeting can blow a whole afternoon, by breaking it into two pieces each too small to do anything hard in. Plus you have to remember to go to the meeting. That’s no problem for someone on the manager’s schedule. There’s always something coming on the next hour; the only question is what. But when someone on the maker’s schedule has a meeting, they have to think about it…. I find one meeting can sometimes affect a whole day. A meeting commonly blows at least half a day, by breaking up a morning or afternoon.”

Therefore, at Above the Fold, we hold internal reviews at 5:00 pm, check-in meetings at lunchtime, and client calls first thing in the morning. This gives our creative team the time they crave to get engrossed in projects, without interruption.

This doesn’t solve the issue of interruption via email, of course. Try scheduling specific “Check email” times into your day—again, first thing in the morning, just before your lunch break or at the end of the day works well. Make sure your team is aware that you will not be responding to emails immediately, and suggest they call you or come find you if something is urgent and relevant to the current project. Team members can be surprisingly understanding and can quickly grasp the difference between imperative and interesting.

3. Use Your Team

“Separate brainstorming (idea generation) from synthesis (putting it all into a flowing post).”

– Tim Ferriss, author

Having large blocks of time available and scheduling them into your day sounds well and good, but how do you convince your brain that the time has come to get in the zone and ignore distractions?

Taking a page out of the Agile development book, try starting with a variation on pair programming. Pair programming is designed to help developers break down complex tangles of code with the simple rationale that two heads are better than one. The same is true for kicking off any other sort of creative block of time. Instead of working together all day, kick off the day with a 10-minute group brainstorming session. Nothing focuses the creative mind faster than talking through project details, and 10 minutes can lead to a far more productive three hours of synthesis.

Don’t have a team to kick around ideas with? Hit up a few colleagues on Twitter or Skype. We have found that many in the content and design worlds are happy to help, and you can offer to help in return.

4. Warm Up Your Muscles

“Major league players aren’t the only professionals that regularly practice. We’ve met musicians, firemen, pilots, and surgeons, all of who regularly practice their skills.”

– Jared M. Spool, founding principal of User Interface Engineering

Athletes warm up their muscles before starting their real work, and so should creative thinkers. A good warm-up helps you practice basic skills, focus your mind and improve the work to come. In addition, taking 10 minutes to warm up allows you to separate your ideas from the plethora of ideas surrounding you.

A few hundred years ago, visual stimulation was hard to come by, and artists were influenced primarily by their surroundings. Now, our surroundings contain hundreds of representations of our surroundings and of other people’s interpretations of their surroundings. Finding your own voice can be difficult amid the clutter.

The following quick warm-ups can bring you back to basics and isolate what makes your creative voice unique. Some of these suggestions even include using someone else’s work as a starting point—but making it your own.

Write your thoughts down in a journal.
Doodle for 10 minutes in a sketchpad.
Copy the first sentence of a book, and then write a one-page story that begins with that sentence.
Create three variations of a landing page based on different mood themes (happy, scary, sad, etc.).

None of these warm-ups should take more than 10 minutes, and each offers a different way to reconnect you to your creative spirit. From here, you might find it easier to begin thinking about new and different ideas, and even jumpstarting a project that has felt stale.

5. Save The Best For Last

“Laziness in a white collar job has nothing to do with avoiding hard physical labor. “Who wants to help me move this box!” Instead, it has to do with avoiding difficult (and apparently risky) intellectual labor.”

– Seth Godin, entrepreneur, author and speaker

Most creative jobs come with a catch, such as having to respond to client emails, send invoices or email writing samples. It’s not uncommon for these boring, “uncreative” tasks to turn into a means of procrastination. You feel as though you can’t set a task aside because it must be done; but because you don’t want to do it, you procrastinate—effectively avoiding both your creative work and your busywork.

Invoices and emails and bills are quick tasks, so we don’t feel as though delaying them by an hour or two costs much. But the hour you spend avoiding a five-minute task eats away at your creative time. What’s more frightening is the possibility that you’re actively using these tasks to avoid your creative work. As Seth Godin explains, this is due to “lizard brain”:

“The [lizard brain, or resistance,] is the voice in the back of our head telling us to back off, be careful, go slow, compromise. The resistance is writer’s block and putting jitters and every project that ever shipped late because people couldn’t stay on the same page long enough to get something out the door.”

We’ve all dealt with lizard brain, and many of the suggestions in this article can help combat it. But how do you remove the procrastinations that are genuine work, the busywork that must be done but just gets in the way?

Try setting aside one morning a week (Monday is a good day) to devote to the boring tasks. Relegate email reminders of the busywork to a “Monday” folder. Keep all physical folders and to-do lists for that work away from your desk. Of course, you don’t want to wake up one day and realize you forgot to pay the bills, but you won’t forget housekeeping chores like that if you assign them to a specific time slot—and not that generic “tomorrow.”

One more tip: don’t sit in your creative spot to do the busywork. The area for busywork will quickly get cluttered with to-do notes that have nothing to do with the creative work that you need to accomplish. Do the necessary evils somewhere else to avoid distracting yourself the next time you begin your “real” work.

Untamed Creativity

Saying that a wild creative mind can’t be tamed sounds romantic, but romanticism will serve you better in your actual products than in your schedule. The advice above will help you schedule your mind, enhance your creativity and use team members, time constraints and even deadlines to your advantage. Give your creative mind the structure and security it needs to run wild.

Other Resources

Here are some more resources on creative productivity:

  • “Develop a UX Practice of Practicing”, Jared Spool
    Find ways to warm up before work.
  • “Quieting the Lizard Brain”, Seth Godin
    Learn more about the dreaded lizard brain and why we get in our own way.
  • Gamestorming, Dave Gray
    Explore activities to get you brainstorming in a group. Gray’s book and his Gamestorming website are full of activities and ideas.
  • “How Creativity Works”, Jonah Lehrer
    An interview about all different types of creativity.
  • Time Management for Creative People, Mark McGuinness
    This free eBook deals with how to better structure your creative time.

What other tips and tools help you to be creatively productive?

Read More →

WordPress permanent links not working? GoDaddy issue?

After moving my dev wordpress to its new home, and something very weird happened: some, just some, of the links were not working (for example, the page is not working while other pages are working). They are all pages (and some are categories links as well), some working, some not, no pattern it seems.

I was wondering if there was something wrong with my settings or if I messed up my .htaccess file:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

The host, GoDaddy, is infamous with delay in updating .htaccess, but I didn’t know if it was the case or not. Surely if that happened the whole thing wouldn’t work at all, but here we have some work, some didn’t.

After struggling almost 30 minutes with this issue and even posted this on stackoverflow, I found out the cause. I had a file named contact.php, after i renamed it link started working. Hope this will save others’ time who may run into the same situation.

Read More →