Jump to:

23360 Posts in 18097 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Loading page content on another page

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

Page: 1
Go to End
Author Topic: 1859 Views
  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Loading page content on another page Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5483 Posts

    Re: Loading page content on another page Link to this post

    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 %>

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Loading page content on another page Link to this post

    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

  • PeltierEffects
    Avatar
    Community Member
    6 Posts

    Re: Loading page content on another page Link to this post

    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

    1859 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.