This article is a little odd for my blog perhaps, but there’s a reason. Actually there’s a couple of reasons.
I went through the Victorian bushfire last year, the worst natural disaster in Australian history where 173 people died and thousands were displaced from their homes. Many of those still aren’t able to return as they’ve not yet finalised the details of their rebuild for various reasons. Some of course choose not to come back to the bushfire prone areas and have instead moved to the suburbs.
But even in the suburbs you still need a bushfire plan. The Victorian bushfires of February 2009 that tore through Kinglake, Marysville and half of the Murrindindi Shire, were accompanied by other fires on the day, including one in Narre Warren. The fire in Bendigo on the same day was in a suburban area and destroyed a number of homes, partially I’m sure because people in that area believed they were safe because they were in a suburban area.
Fire-Ready is implemented in CS-Cart
This is where the latest site that I’ve been working on for a customer, fire-ready.com.au comes in. They supply everything you need to help ensure that on the day when bushfire threatens your property and family, you’ll be ready. Fire Ready. Why am I writing about this? Well because I think the site is also a showcase CS-Cart site. It took some doing and lots of blood sweat and tears, but I believe it proves the amazing flexibility of the CS-Cart engine.
How was it done?
The site originated from the original CS-Cart skin – the basic skin. It was then stripped bare, to remove some of the display items that were not needed, and it went through a few iterations while I figured out the best way to tinker with CS-Cart. It soon became clear that one should always try to work within the CS-Cart framework, so I had to learn how to design and code my own blocks, so that these could be added and moved around as the customer required. Although some of the design elements do not lend themselves to being moved around, the CS-Cart engine is strongly oriented towards blocks and rather than hack up the skins to a degree that would make them unsupportable I chose to do these likely unmovable elements as blocks as well.
The CS-Cart knowledgebase is a very handy resource, although unfortunately it is missing a considerable amount of information. But it’s a good place to start learning how to do your own addons and blocks.
I started to write a blog article about how to write CS-Cart blocks, but its quite a complex subject and the article requires some extra editing that I’ve since learned so I will release that shortly and come back here to link to it so others can share the love. But, once you get your head around the CS-Cart architecture it’s really very nice to work with.
One principle that I will share here and now however is that one should never, ever, alter the core CS-Cart files. This is something I’ve learned from the WordPress world, and in some ways programming a CS-Cart skin is a little like working with a WordPress theme. The actual building blocks are very different – CS-Cart uses the Smarty Template System for instance, which WordPress does not – but the architectural decisions are fairly similar. So, you can create your own AddOns (which you’ll just about need to if you want to create your own blocks), which can ‘hook’ into aspects of the CS-Cart functionality using either your own pre/post controller code, or using CS-Cart hooks. Each mechanism has its own pros and cons, which I’ll also try to go into in my next CS-Cart article.
One small thing to note here, if you’re starting to look into writing your own blocks and require access in PHP code to the template variables, you may be tempted to use the Smarty method ‘get_template_vars‘. Don’t. CS-Cart overrides the Smarty object and provides a number of its own methods – most of which are very good and make life a lot easier for you. But there’s also this gotcha – when you use $view->assign, the code internally uses the PHP htmlspecialchars() function to escape any data that may be contained in your template data. However, CS-Cart rather curiously have not overridden the get_template_vars method, instead choosing to create a new method call get_var(). This means that if you use get_template_vars() to get something from the template data it will not be unescaped. If you then re-assign it after you manipulate it, it’ll be DOUBLE ESCAPED. This took me a while to find. Instead, use the CS-Cart provided get_var() function which will unescape your template object for you so that when you manipulate it and put it back it won’t be double escaped.
Anyway, that’s enough for this article for now, please do visit the fire-ready.com.au website, particularly if you’re in Australia and in a bushfire prone area because I believe the website is definitely worth a look.