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, biapar, Willr, Ingo, swaiba, simon_w

Showing the link from a Sitetree variable in CMS




Community Member, 6 Posts

13 April 2011 at 4:19am


Okay, simple question, hopefully simple answer :P

I want to show the URL of my sitetree variable IN the dataobjectmanager, much like the name and description...
However, even if I use 'HomeItemLink.Link' => 'Link' it won't show.
I was wondering if any of you have a solution to this, it's probably something simple that I'm not getting >_<

Example of my HomeItem object code:

class HomeItem extends DataObject {

   static $db = array(
      'HomeItemTitle' => 'Text',
      'HomeItemDesc'=> 'Text'

   public static $has_one = array(
      'HomeItemImg' => 'Image',
      'HomeItem' => 'Homepage',
      'HomeitemLink' => 'SiteTree'
   public function getCMSFields_forPopup() {
       return new FieldSet(
         new TextField('HomeItemTitle'),
         new TextareaField('HomeItemDesc'),
         new SimpleTreeDropdownField('HomeitemLinkID', 'Choose a page to show on the right:', 'SiteTree'),
         new SimpleImageField('HomeItemImg')


Example of my Page.php code:

$manager = new DataObjectManager(
      $this, // Controller
         'HomeItems', // Source name
         'HomeItem', // Source class
            'HomeItemTitle' => 'Name',
            'HomeItemDesc' => 'Desc',
            'HomeItemLink.Link' => 'Link'
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause