Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Page type that uses content from another page

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 2185 Views
  • StarsandStripes
    Community Member
    4 Posts

    Page type that uses content from another page Link to this post

    I saw this in the tutuorial, in that sample picture there's a page type titled: "change to a virtual page that uses another pages content". I assume that Silverstripe let's me fillin the content and it provides all the menus and stuff. That would be really useful when adapting data from other systems into seemingly using SilverStripe. So, where can I get that pagetype?


  • Anatol
    126 Posts

    Re: Page type that uses content from another page Link to this post


    what you have seen in the tutorial is the VirtualPage page type. However, what a virtual page does is to use an existing Silverstripe page, not a page of another system. This is useful e.g. if you have a large site and you want to link to the same content from different places (so you can link to the same page from another navigation or sub navigation level, etc...). The url is different from the original page, but the content is the same.

    Another page type is the Redirector page type but this one only redirects to another page, either a Silverstripe page or an external page. The url changes to the url of the original page (it's really just like a link to another page in your navigation).

    Both VirtualPage and Redirector are standard page types that come with the Silverstripe CMS.

    But I guess that what you are looking for is probably different. It should not be too difficult to create a new page type that just loads the content from a defined url into the Silverstripe content and keeps the Silverstripe navigation, etc, but I imagine that in most cases this is not very practical and different style sheets etc could easily break the design. You would probably have to parse the data of the external page and remove the header, html and body tags, style sheets and possibly some other tags to get a clean result. I could also imagine that a page that loads content from another url is slower than a real Silverstripe page.

    If you want to create that page type you may want to look at some PHP functions, e.g. file_get_contents or http_get_request_body, just to get you started.


  • StarsandStripes
    Community Member
    4 Posts

    Re: Page type that uses content from another page Link to this post

    OK, great, thanks! Is there a tutorial for creating a custom page type? It would be nice to have some code that I just could get a jumpstart from.



  • Willr
    Forum Moderator
    5508 Posts

    Re: Page type that uses content from another page Link to this post

    Tutorial 2 covers adding page types to the system. At the very basic level all you need is


    class MyNewPageType extends Page {}

    class MyNewPageType_Controller extends Page_Controller {}


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.