17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 2142 Views |
-
adding a page type, a couple of questions....

7 September 2007 at 2:29pm Last edited: 7 September 2007 2:33pm
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
-
Re: adding a page type, a couple of questions....

7 September 2007 at 6:32pm Last edited: 7 September 2007 6:35pm
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
-
Re: adding a page type, a couple of questions....

7 September 2007 at 6:45pm Last edited: 7 September 2007 6:54pm
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 -
Re: adding a page type, a couple of questions....

7 September 2007 at 7:10pm
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?
-
Re: adding a page type, a couple of questions....

7 September 2007 at 10:38pm
What did you do to achieve that problem? You could try adding ?flush=1 at the end to see if that helps...
Cheers,
Sean -
Re: adding a page type, a couple of questions....

7 September 2007 at 11:42pm Last edited: 10 September 2007 3:02pm
..... quoted error here.....
-
Re: adding a page type, a couple of questions....

8 September 2007 at 12:08am Last edited: 8 September 2007 12:10am
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
| 2142 Views | ||
| Go to Top | Next > |


