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.

Data Model Questions /

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

Access page details from linked pages in GridField?

Go to End



Community Member, 141 Posts

15 April 2013 at 8:22am

I added a GridField to my pages to store related pages. Currently I just store the link to the related page in the GridField but I'd like to have all details of the related page (content, title, etc.) in my page templates. How do I get access to all that data? Do I have to load them in my page.php or is there a way just within my templates?

In my template I don't have access to the content and other details of the related page. Only the fields from the GridField.

<% control RelatedPages %>
		<% end_control %>

function getRelatedPages() {
	return DataObject::get("RelatedPage");

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

		$displayColumns = new GridFieldDataColumns();
			'Relted.MenuTitle' => 'Resort'

		$gridFieldConfig = GridFieldConfig::create()->addComponents(
			new GridFieldToolbarHeader(),
			new GridFieldAddNewButton('toolbar-header-right'),
			new GridFieldEditButton(),
			new GridFieldDeleteAction(),

	    $gridField = new GridField("Related", "Pagelist", $this->relatedPages(), $gridFieldConfig);

	    $fields->addFieldToTab("Root.Main", $gridField);

		return $fields;