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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Link Page with multiple pages with GridField

Go to End

3 Posts   792 Views


Community Member, 2 Posts

10 October 2013 at 10:07pm

Edited: 10/10/2013 10:08pm

I want to add a form where the user in the backend can link a page with multiple other pages. Something like "You might also be interested in..." but NOT dynamically generated.
I found this tutorial:
but the problem is, that when I set a relation the site tree is modified.
What I want is something like:
Frontpage is linked with About page
Contact page is linked with About Page and Imprint

How do I have to modify this code to achieve this?

public static $has_many = array(
	  'Boxes' => 'Page'

	public function getCMSFields() {
	  $fields = parent::getCMSFields();
	  $gridFieldConfig = GridFieldConfig_RelationEditor::create()->addComponents(
			new GridFieldDeleteAction('unlinkrelation')
	  $gridField = new GridField("Boxes", "Boxes", $this->Boxes(), $gridFieldConfig);
	  $fields->addFieldToTab("Root.Boxes", $gridField);
	  return $fields;


Community Member, 2 Posts

11 October 2013 at 4:35am

With help of this post I'm able to select multiple posts, but the values are not saved and I cannot access them from my template.
How can I save my selection in the database and access them from my template?


Community Member, 545 Posts

14 October 2013 at 6:48pm

I suspect you're trying to assign a $has_many with a corrsponding $has_one relation. Also realitistally what you probably want is for Page to have $many_$many $belong_many_many relation with itself since any page can actually belong to multiple other pages