CMS Made Simple Forums

Colour changing Storage Units with CMSms
Page 1 of 1

Author:  Simon66 [ Tue Jun 25, 2013 6:16 am ]
Post subject:  Colour changing Storage Units with CMSms

The site

I recently created a quick and dirty site for a local storage unit business. We owed them some money for a unit so I agreed to update their site instead.
I shamelessly ripped the html out of an old drupal site of mine which explains the horrific amount of nested divs.
It's not much to look at, but believe me it's 100 times better than what was there before.

The bit that I was expecting to be hard was the unit facility map -

The client wanted to be able to visually see which units were available and unavailable.

I decided to try a vector SVG file for this and control the colour changing from within CMSms.

I used Inkscape ( It's FREE) to draw the map as it natively saves files in SVG format. (They still need to be exported as simple SVG).

Now IE8 doesn't support SVG at all - it just displays the raw XML code.
Again I thought this was going to be hard but after a couple of failed solutions I found a javascript SVG Web toolkit -

This was as simple as a javascript call in the head and wrapping the SVG code in a script tag:

<__script__ src="svg.js"></__script>

<__script__ type="image/svg+xml">
SVG Code in Here.

And Hey-Presto SVG works in IE8 (it actually gets converted to Flash on the fly).

How I made the colour changing Storage Units.

I installed CustomGS (Custom Global Settings) and created 40 numbered checkboxes - 1 for each unit.

The SVG file contained the following code for each unit:

       style="fill:#aadff8;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.99;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />

I swapped out the fill colour with the CustomGS variable, and the last line ended up looking like this:

       style="fill:{if $CustomGS.Storage_Unit_16 == '1'}#FF0000{else}#aadff8{/if};fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.99;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />

Notepad++ and Firebug are the two best tools for this kind of thing.
Firebug found the ID of each unit and Notepad++ has an excellent find and replace.

A neat little app I was very happy with and the whole site took less than a day.


File comment: Availability checkboxes in CustomGS.
admin.png [ 71.34 KiB | Viewed 1253 times ]
File comment: vector SVG map embedded in site template.
site.png [ 149.96 KiB | Viewed 1253 times ]

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group