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.

Archive /

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

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

Page type that uses content from another page


Reply


4 Posts   2218 Views

Avatar
StarsandStripes

Community Member, 4 Posts

6 August 2008 at 10:08pm

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?

http://doc.silverstripe.com/doku.php?id=tutorial:1-building-a-basic-site#changing_the_page_type_of_the_home_page

Avatar
Anatol

126 Posts

7 August 2008 at 9:44am

Hi,

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. [url=http://www.php.net/manual/en/function.file-get-contents.php]file_get_contents[/url] or [url=http://www.php.net/manual/en/function.http-get-request-body.php]http_get_request_body[/url], just to get you started.

Cheers!
Anatol

Avatar
StarsandStripes

Community Member, 4 Posts

7 August 2008 at 11:41am

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.

TIA,

Patrik

Avatar
Willr

Forum Moderator, 5513 Posts

7 August 2008 at 12:53pm

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

<?php

class MyNewPageType extends Page {}

class MyNewPageType_Controller extends Page_Controller {}

?>