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.

Customising the CMS /

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

Adding editable include to page.ss


Go to End


3 Posts   1242 Views

Avatar
whjonker

Community Member, 12 Posts

27 October 2016 at 8:29am

Hi guys,

I would like to include an agenda that should be displayed on each page. This agenda should be editable in the CMS. I have tried multiple things. Creating a new page type (calendarPage.php and calendarPage.ss) and included that as <% include CalendarPage %> on page.ss, but this does not work. Also adding
<% loop $Children %> <% include CalendarPage %><% end_loop %> does not work. There is probably a very easy way. Hope that someone can help me with thos.

Thank you!

Wesley

Avatar
blackduck

Community Member, 13 Posts

27 October 2016 at 3:30pm

Edited: 27/10/2016 3:34pm

If you're trying to include content from a single page onto multiple pages the easiest way is
<% loop Page("<urlsegment>") %>
$Content
<% end_loop %>
Using $Content or whatever part of the page you're after.

Avatar
whjonker

Community Member, 12 Posts

2 November 2016 at 9:36pm

Thank you for you reply. I tried your suggestion, but somehow it did not work out for me.

So now I added to page.php

function ShowCalendar(){
$get = DataObject::get_one('CalendarPage');
return new CalendarPage_Controller($get); }

and to the page.ss I added

<% control ShowCalendar %>
$Date_1
<% end_control %>

This also did the magic. Thanks again

Wesley