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

How do I have "special" pages were the content is generated by a PHP script?


Reply

5 Posts   1348 Views

Avatar
MKayHavoc

3 June 2008 at 2:39am Community Member, 33 Posts

Hi,

Might sound a bit strange, but I'm wondering how I can have pages on a site that are kind of managed by the CMS as in they appear in the navigation etc, but the content of the page is generated by a custom PHP script.

For example I have a script that generates a telephone directory and displays it, how would this integrate into the CMS?

Cheers

Avatar
Willr

3 June 2008 at 8:27pm Forum Moderator, 5511 Posts

just create a page type MyPage.php then create one of these in the CMS. Then in the MyPage_Controller you can overload a method called Content to set the content from your PHP Script instead of the Content from the CMS or use a MyPage template to send custom content

Avatar
MKayHavoc

3 June 2008 at 9:02pm Community Member, 33 Posts

OK, sound sensible. How do I create a custom page type?

Avatar
Willr

3 June 2008 at 9:14pm Forum Moderator, 5511 Posts

Read the second tutorial so you have the understanding behind this but create a file named whatever for this example ill call it DirectoryPage.php. Create this in the mysite/code folder

<?php

class DirectoryPage extends Page {

static $db = array();

}
class DirectoryPage_Controller extends Page_Controller {

function Content() {
// your php function
return $SomeText;
}

}

Then visit http://www.yoursite.com/db/build?flush=1. Next in the CMS you need to create a new page of type - DirectoryPage and you should have a custom page. Read tthe tutorials for a bigger overview

Avatar
MKayHavoc

3 June 2008 at 9:27pm Community Member, 33 Posts

Ah, that's great. OK, i'll read the tutorial for more details. Cheers.