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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

CustomSiteConfig content from tabs --> to html content


Go to End


3 Posts   887 Views

Avatar
jouni

Community Member, 3 Posts

23 November 2011 at 10:23pm

I have a sidebar in my site where should be a logo list.
Logos would be editable from backend.

I think I have done my backend stuff, CustomSiteConfig and datamodel correctly,
but I don't know how to pull this information into html content.

CustomSiteConfig.php

<?php

class CustomSiteConfig extends Extension {
   
   function extraStatics() {
      return array(
         'has_many' => array(
            'Logos' => 'Logo'
         )
      );
   }

   public function updateCMSFields(FieldSet &$fields) {
      
      $manager = new DataObjectManager(
         $this->owner,
         'Logos',
         'Logo',
         Logo::$summary_fields,
         'getCMSFields_forPopup'         
      );   
      $fields->addFieldToTab("Root.Logot", $manager);
      
   }

}

Logo.php

<?php

class Logo extends DataObject
{
static $db = array (
	'Name' => 'Text',
	'AltText' => 'Text',
	'Link' => 'Text'	
);
	
	
	
static $has_one = array (
	'SiteConfig' => 'SiteConfig',
	'LogoImage' => 'Image',
	'LogoPage' => 'SiteTree'
);
	
public function getCMSFields_forPopup()
	{
		return new FieldSet(
			new TextField('Name'),
			new TextField('Link'),
			new TextField('AltText'),
			new ImageField('LogoImage')
		);
	}
}
 
?>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

24 November 2011 at 4:17pm

<% control SiteConfig.Logos %>

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
jouni

Community Member, 3 Posts

24 November 2011 at 8:52pm

<% control SiteConfig.Logos %>
$Name
<% end_control %>

Like this?
It just doesn't work.. Maybe there's something from with my files after all :(