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

How to display page link in headers array of DataObjectManager


Go to End


915 Views

Avatar
aragonne

Community Member, 26 Posts

4 March 2011 at 12:15am

Edited: 04/03/2011 6:54am

Hi,

I have a DataObject managed by AdminConsole and contains a DataObjectManager where I want to display a page's link in the headers array:

Class FeedClient extends DataObject {

    static $belongs_many_many = array( 'TestPages' => 'TestPage');

    function getCMSFields() {
        $fields = parent::getCMSFields();

        $fields->addFieldToTab('Root.Main', new ManyManyDataObjectManager(
            $this,
            'TestPages',
            'TestPage',
            array(
                'MenuTitle' => 'Menu Title'
                ,'PageLink' => 'Page Link'  /*** headers array: hoping to display the TestPage's link with this but not working ***/
            ),
        ));
        return $fields;
    }
}

The TestPage page type:

class TestPage extends Page {
    static $many_many ('FeedClients' => 'FeedClient')
...
    function getPageLink() {
        return $this->Link();
    }
}

I realize that problem is that TestPage doesn't have a PageLink data field so based on some posts I read, I created a getPageLink() method and try to specify 'PageLink' in the headers array of the DataObjectManager, hoping it would display the page's link, but the CMS returns an error that says PageLink is not a field, as expected.

Is it possible to display the page's link in the DOM's headers array?

thanks!
Steve