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.

Template Questions /

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

Display a specific page content (all content) on another page?

Go to End

2 Posts   320 Views


Community Member, 143 Posts

14 March 2017 at 3:30pm

Hi to all, how can i display the whole content (all whats inside my page type: data objects, html tags, etc) of a page within another page? If that would exist, that is what id need: <% control Page(my-page) %>$all_content<% end_control %> - Thanks!


Community Member, 60 Posts

31 March 2017 at 8:54pm

Create a function in your Page_Controller that gets the page and returns it. eg:

//Page controller - you would need to specify an appropriate query to get whatever page you are after
public function MyPage(){
  $page = Page::get()->First();
   return $page;

//template for SS 3+ If function returns one page use 'with', if function returns more than one page use 'loop'
<% if MyPage %>
  <% with MyPage %>
   //if the page had a has_many relationship to another dataobject (eg GalleryImages) you can use that within 
  <% if GalleryImages %>
   <% loop GalleryImages %>
   <% end_loop %>
 <% end_if %>
 <% end_with %>
<% end_if %>