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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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

[SOLVED] Calling CustomSiteConfig DataObjects in 2.4


Go to End


10 Posts   2680 Views

Avatar
Pyromanik

Community Member, 419 Posts

3 March 2015 at 4:30am

Edited: 03/03/2015 4:31am

Good to hear :)
Except now this is completely redundant (it won't work anyway):

function MyFoom() {
	return DataObject::get( 'CustomSiteConfig', "`MyFooterItemID` = '{$this->ID}'" );
}

simply call $thatItem->MyFooter() to get the SiteConfig that FooterItem is related to.
Although personally I'd call that relation something a bit less confusing ($has_one = ['Site'=>'SiteConfig']; perhaps)

Avatar
ambient

Community Member, 130 Posts

3 March 2015 at 4:52am

Oops, I meant to delete that, thanks again :)
FooterItem.php

<?php

class FooterItem extends DataObject {
	
	static $db = array(
		
		'FooterText' => 'Text',
		'FooterLink' => 'Text'
	);
	
	static $has_one = array(
		//'FooterImage' => 'Page_Image',
		'MyFooter' => 'SiteConfig'
	);
	
	
	
	function getCMSFields_forPopup() {
    $fields = new FieldSet();
 
    $fields->push( new TextField('FooterText', 'Text' ) );
    $fields->push( new TextField('FooterLink', 'Link' ) );
 
    return $fields;
		}
		
	
	
}

Go to Top