Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Custom Site Config!

Go to End

6 Posts   1048 Views


Community Member, 10 Posts

24 June 2014 at 9:51am


I am trying to create some site wide content which will reside in the footer area of my site. I have created a DataExtension to extend siteconfig, which includes a DataObject as this is basically for sponsor images and you need to be able to add and remove as many as necessary.

From the backend I seem to have everything working, but don't seem to be able to access the data through the template, here is my code:


class CustomSiteConfig extends DataExtension {

private static $has_many = array(
'Sponsors' => 'Sponsor'

public function updateCMSFields(FieldList $fields) {

$config = GridFieldConfig_RelationEditor::create();

'Link' => 'Link'

$sponsorfield = new GridField(
new DataList('Sponsor'),

$fields->addFieldToTab('Root.Main', $sponsorfield);




class Sponsor extends DataObject {

static $db = array (
'Link' => 'text',

static $has_one = array (
'SiteConfig' => 'SiteConfig',
'Image' => 'Image',

public function getCMSFields() {
$sizeMB = 2; // 2 MB
$size = $sizeMB * 1024 * 1024; // 2 MB in bytes

$uploadField = new UploadField('Image', 'Sponsor Image');


$fields = new FieldList(
new TextField('Link'),

return $fields;


I have also updated the file in /framework/_config/config.yml to read:

- CustomSiteConfig

In my template I am trying to access the data like this:

<% loop $SiteConfig.Sponsors %>


<% end_loop %>

Unfortunately this is not working for me, any ideas anyone?

Many Thanks


Forum Moderator, 240 Posts

25 June 2014 at 5:27pm

Something to check would be to ensure your yaml config file is using 2 spaces indentation and that you have build the database with dev/build and run a flush.


Community Member, 10 Posts

25 June 2014 at 8:13pm

Hey Camfindlay,

Thanks for your suggestion, the .yaml file is correctly indented and I did rebuild and flush! Still no joy here!

I was wondering if I am trying to access the data in the template the correct way?




Forum Moderator, 240 Posts

25 June 2014 at 9:41pm

Yep I believe you are doing it correctly, I have just tried the code on a fresh 3.1.x core code and got it to work.

Here is my code example + a few changes as to how I would have approached it. Let me know if you have any questions.


Community Member, 41 Posts

7 July 2014 at 5:44am

Usually for something like this, I would just use ModelAdmin. Easier and clearer I think. For a client going into a sponsors section makes more sense than going into settings.


Community Member, 54 Posts

8 July 2014 at 8:32am

I normally add some footer tabs to my home page and write a getter....