Skip to content

Instantly share code, notes, and snippets.

@chillu
Last active December 16, 2015 07:08
Show Gist options
  • Save chillu/5396571 to your computer and use it in GitHub Desktop.
Save chillu/5396571 to your computer and use it in GitHub Desktop.
<?php
class WidgetArea extends DataObject {
static $belongs_many_many = array(
'Pages' => 'Page'
);
static $many_many_extraFields = array(
'Pages' => array(
'SectionName' => 'Varchar'
)
);
}
class Page extends SiteTree {
static $many_many = array(
'WidgetAreas' => 'WidgetArea'
);
}
class TextWidget extends Widget {
static $db = array(
'Content' => 'Text',
);
}
class AdWidget extends Widget {
static $db = array(
'Content' => 'Text',
'Height' => 'Int'
);
}
class ImageWidget extends Widget {
static $has_one = array(
'Image' => 'Image',
);
}
Page.ss
$Content
<% WidgetArea('sidebar') %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment