Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [SOLVED] Page Links in DOM

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 882 Views
  • NickJacobs
    Community Member
    144 Posts

    [SOLVED] Page Links in DOM Link to this post

    Hi, I'm trying to output images in a sidebar which link to other pages in the site. I've got it working fine, but just cannot get the page links to output. I'm sure it's something easy I'm overlooking....hopefully someone else can spot it ....


    class LinkImageItem extends DataObject
       static $db = array (      
          'Caption' => 'Text'
       static $has_one = array (
          'LinkImage' => 'Image',
          'Page' => 'Page',
          'Link' => 'SiteTree'
       public function getCMSFields_forPopup()
          return new FieldSet(
             new TextField('Caption','Caption'),
             new SimpleTreeDropdownField("LinkID", "Select a page to link to", "SiteTree"),
             new ImageField('LinkImage','Link Image')


    class Page extends SiteTree {
       public static $db = array();
       public static $has_one = array();
       public static $has_many = array(   
       'ResourceFile' => 'File',
       'LinkImageItems' => 'LinkImageItem'   
       static $icon = "themes/smartpack/images/treeicons/page";   
       public function getCMSFields()
          $f = parent::getCMSFields();
          $f->addFieldsToTab("Root.Content.ResourceFiles", new AssetManager($this,"ResourceFiles","ResourceFile"));
          // setup the page link images
          $manager = new ImageDataObjectManager(
             $this, // Controller
             'LinkImageItems', // Source name
             'LinkImageItem', // Source class
             'LinkImage', // File name on DataObject
             array('Name' => 'Name'),
             'getCMSFields_forPopup' );
          return $f;

    In Page.ss

    <% control LinkImageItems %>

    <a href="$Link">$Caption</a>

    <% end_control %>

    Tried all sorts of different ways in the template, but the link never outputs (everything else does)

    any ideas??

  • UncleCheese
    4085 Posts

    Re: [SOLVED] Page Links in DOM Link to this post

    "Link" is a really bad choice of a fieldname because it is a function on SiteTree objects. But assuming that's not an issue, you have $Link returning a SiteTree object, so the correct code would be $Link.Link

  • NickJacobs
    Community Member
    144 Posts

    Re: [SOLVED] Page Links in DOM Link to this post

    Hi, thanks, I've renamed Link to PageLink, and $PageLink.Link works as it should.


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.