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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[SOLVED]Content from one page on multiple pages


Go to End


4 Posts   3501 Views

Avatar
shluckey

Community Member, 19 Posts

4 August 2012 at 5:27am

Alright guys I know this is probably really simple but I couldnt think how to phrase it to search for a solution.

I want to take the cms input from my homepage and have it appear in multiple other pages.

eg. User inputs 'latest news' on homepage and I show it on several other sub pages. $LatestNews on homepage and other templates.

Something to do with specifying the children of homepage in the HomePage.php file?

Avatar
jak

Community Member, 46 Posts

4 August 2012 at 10:07pm

Have a look at the tutorial, it explains how this can be done: http://doc.silverstripe.org/framework/en/tutorials/2-extending-a-basic-site#showing-the-latest-news-on-the-homepage

You will have to adapt it to your code, but the basic idea is the same: Get the page that contains the information you need by using MyPageType::get() and then access the field that you are interested in.

Avatar
DesignerX.com.au

Community Member, 107 Posts

5 August 2012 at 8:16pm

Edited: 05/08/2012 8:20pm

Hi:
Quick & easy solution is :
<% control page(URLSegmentHere) %>
$LatestNews
<% end_control %>

by doing <% control page(home) %> you move to that page scope .. so everything on the home page can be shown here , Example:
<% control page(home) %>
$Title //Shows Home
$Content //get content from Home page
$OtherFunction
<% end_control %>

Avatar
shluckey

Community Member, 19 Posts

7 August 2012 at 8:39pm

thank you very much for both replies