Monday 12 December 2011

SilverStripe - Adding Checkbox to CMS

SilverStripe - Adding Checkbox to CMS

This allows you to add a checkbox to CMS, and then display stuff in the frontend dependant on if it is ticked or not.

First you need to add the database field for it.

static $db = array(
'ShowExtraClass' => 'Boolean'
);

Then add the checkbox to the cms

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new CheckboxField ("ShowExtraClass"));
return $fields;
}

And finally you add the if statement in your template:
<% if ShowExtraClass %>

click here for the original website

Friday 9 December 2011

Magento - add image to phtml

Magento - add image to phtml
<img src="<?php echo $this->getSkinUrl('images/cassa/banner-overlay.png') ?>" alt="" id="banner-overlay" />