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" />

Tuesday, 29 November 2011

Magento - Displaying Content on a product page depending on a product attribute

Magento - Displaying Content on a product page depending on a product attribute

This allows you to select a attribute in the cms that defines whether something shows up on a product page.

click here for the original website

Thursday, 24 November 2011

Magento - Resize images

Magento - Resize images

The code below shows you how to proportionately resize an image to fit a box with the width 200px and height 100px.

->keepAspectRatio(TRUE)->resize(200,100)

click here for the original website

Wednesday, 23 November 2011

Friday, 18 November 2011

Magento - local.xml

Magento - local.xml

Allows you to edit the layout of pages without the need to modify magento xml layout files

click here for the original website