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.

General Questions /

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

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

Loading page content on another page


Reply


4 Posts   1933 Views

Avatar
steve_nyhof

Community Member, 224 Posts

18 March 2010 at 2:26am

Edited: 18/03/2010 2:27am

I want to load page content from another page into another page, by using the site tree dropdown. I have everything in place, but I am not sure how to add the code to grab the page...

This works

<div class="typography"><h1><% control Title %>$XML<% end_control %></h1>
<% control Page(disclaimer) %>$Content<% end_control %></div>

This does not

<div class="typography"><h1><% control Title %>$XML<% end_control %></h1>
<% control Page(MyDataFieldName) %>$Content<% end_control %></div>

My page code... All seems to do well.

$fields->addFieldToTab('Root.Content.Main', new TreeDropdownField('DuplicateContentPage', 'Select Page:', 'SiteTree', 'URLSegment', 'MenuTitle'));

In the databse, the value is 0 (zero), and I need it to be the page name - like home, or special-footer

Thank you
Steve Nyhof

Avatar
Willr

Forum Moderator, 5513 Posts

18 March 2010 at 12:08pm

You can't pass variables into statements (like foo($Bar)) which is what you're doing. Instead what you should be doing is having a relationship between the pages then you can go <% control ThatOtherPageThisRelatesTo %>$Content<% end_control %>

Avatar
steve_nyhof

Community Member, 224 Posts

18 March 2010 at 12:24pm

Thank you willr,

I had a feeling it would need to be done that way. I finally hired a full time programmer but have him busy with other things right now, but your statement will give him some direction.

Thank you,
Steve Nyhof

Avatar
PeltierEffects

Community Member, 6 Posts

7 April 2011 at 4:02pm

Okay, I've tried for a week. I am sure I am missing something small. On my homepage I have a little section where special information can be pulled into display. On pages other than the homepage I put in a couple of sidebar sections that can be edited in the CMS then just pulled into the page. But trying to build this similar idea for the homepage I am missing something. I created every thing the same as I did for my sidebar sections, did a dev build, in the CMS I see I can put the page type of homespecial. I built a page and put content in it. But the content from the CMS will not display. I know the section is there because I can see the <div>...</di> for the homepage.ss file. In homepage.ss I have

            <% control HomeSpecial %>
               $Content
            <% end_control %>

So, what am I missing.

Thanks