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

adding a page type, a couple of questions....


Go to End
Reply

11 Posts   2432 Views

Avatar
Nicolaas

7 September 2007 at 2:29pm (Last edited: 7 September 2007 2:33pm), Forum Moderator, 213 Posts

Hi,

I successfully added some page types, like this:

class consultingPage extends Page {
static $db = array();
static $has_one = array();
public function pageCodeForCss() {
return 'consulting';
}
}

class consultingPage_Controller extends Page_Controller {

}

I have updated the database, and consultingPage is now a page type. Here are some questions I have:

1. What is the proper way to delete the pagetype again?

2. How can I access the extra variable I would like to add to the pageType from within the .ss templates?

3. within the CMS, how can I change the add pagetype list? I want certain templates only to be available in certain parts of the sites, plus, I dont really want the newsletter option to be available, etc...

Thanks

Nicolaas

Avatar
Willr

7 September 2007 at 6:32pm (Last edited: 7 September 2007 6:35pm), Forum Moderator, 5511 Posts

1. What is the proper way to delete the pagetype again?

Delete the pagetype.php file, rebuild the database is probably the easiest way to go about deleting it!!

2. How can I access the extra variable I would like to add to the pageType from within the .ss templates?

if you make a function like this on your page controller

[code php]
function pageCodeForCSS() {
//
return $code;
}

you should be able to access $code in the SS template like $pageCodeForCSS OR you can have <% control pageCodeForCSS %>$Code<% end_control %>

3. within the CMS, how can I change the add pagetype list?

I dont believe you can edit this list currently and hide/show options just yet sadly, this may be something we have in the future eg Only showing BlogEntrys on BlogHolders... I dont think it goes that far at the moment

Avatar
Sean

7 September 2007 at 6:45pm (Last edited: 7 September 2007 6:54pm), Forum Moderator, 921 Posts

1. Make sure any pages using that class name are reset back to Page before deleting the php file and rebuilding the database. Otherwise, you'll get an error about 'templates not found' or 'couldn't find this class name'.

2. Accessing an extra variable? if you've added it to the static $db = array() then you can call it directly. eg. static $db = array('CoolThing' => 'Text');

You then just use $CoolThing in your template

3. There currently isn't any functionality supporting this, I don't believe. However, you could probably go about doing this starting with SiteTree.php.

Cheers,
Sean

Avatar
Nicolaas

7 September 2007 at 6:45pm Forum Moderator, 213 Posts

Thanks a million!

Avatar
Nicolaas

7 September 2007 at 7:10pm Forum Moderator, 213 Posts

Hi

I have just done this, but I get a bad error:

<b>Fatal error</b>: Class 'about' not found in <b>/home/winsboroughconz/www/sapphire/core/Object.php</b> on line <b>71</b><br >

I have not changed anything in the about class!

What did I do wrong?

Avatar
Sean

7 September 2007 at 10:38pm Forum Moderator, 921 Posts

What did you do to achieve that problem? You could try adding ?flush=1 at the end to see if that helps...

Cheers,
Sean

Avatar
Nicolaas

7 September 2007 at 11:42pm (Last edited: 10 September 2007 3:02pm), Forum Moderator, 213 Posts

..... quoted error here.....

Avatar
Sean

8 September 2007 at 12:08am (Last edited: 8 September 2007 12:10am), Forum Moderator, 921 Posts

It's likely the home page had a ClassName field in the db set to a custom class name, and when you removed that class and rebuilt the database it would've set it to blank because it doesn't exist anymore. Because of that, it's attempting to compensate by using the class name of 'SiteTree' instead as a fall back measure.

Solution? Jump into phpMyAdmin, set the ClassName field for the home page back to 'Page'.

Cheers,
Sean

Go to Top