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.

Content Editor Discussions /

Forum for content editors and CMS users.

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

Passing site-wide data to template


Go to End


1610 Views

Avatar
RobinJG

Community Member, 7 Posts

1 September 2015 at 4:06pm

I have a page that then has dynamic sub pages: http://hbaf.webranger.co.nz/shows/event/323309
My problem is when I go to the sub page I don't get the Site-wide variables I set up in my Page.php controller.
This is what is set up in my Page.php controller:
//GET HOME PAGE SITEWIDE VARIABLES FOR DISPLAY ACROSS WEBSITE
public function HomePageFields() {
$HomePage_return = HomePage::get()->byId(1);
return $HomePage_return;
}

In my templates I use: $HomePageFields.Sponsors_1

But when I use return $output[0]->renderWith('EventPage');
My EventPage.ss templates doesn't display any $HomePageFields data.

I hope this is clear enough.
Cheers

Robin