Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Showing the link from a Sitetree variable in CMS

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

Page: 1
Go to End
Author Topic: 583 Views
  • fengdeadshot
    Avatar
    Community Member
    6 Posts

    Showing the link from a Sitetree variable in CMS Link to this post

    Hey,

    Okay, simple question, hopefully simple answer

    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:

    <?php
    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
             array(
                'HomeItemTitle' => 'Name',
                'HomeItemDesc' => 'Desc',
                'HomeItemLink.Link' => 'Link'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );

    583 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.