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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page Type Buider...?


Reply


6 Posts   834 Views

Avatar
biapar

Forum Moderator, 435 Posts

25 June 2009 at 7:14pm

Hi,

there is form builder , but there is a page type builder for extending page base type for making a type usable to create page?

Avatar
CrazyCoders

Community Member, 32 Posts

26 June 2009 at 6:04am

Unless you want to simply have several templates, there is virtually no need to have a page type builder. Page types are usually to create controllers or additionnal database content to store in the DB. No matter the time involvement to create such a thing, it could never be perfect, so it a little pointless to do so.

If you want to add page types but don't know programming, know that it is very simple to Copy and Paste the Page.PHP file under "mysite/". You then just open the file and change the "class Page extends SiteTree" for "class xzy extends Page" and you also change the "page_controller extends ...(something)..." to "class xyz_controller extends page_controller".

Thats all...

Avatar
Sam

Administrator, 685 Posts

26 June 2009 at 4:16pm

Hi biapar,

Our page types are represented as PHP classes, and this would make the creation of a page type editor quite a task - you would need to make a system for generating code, which would need to be extremely robust to ensure that developers' alterations to the code files were never lost. It could be done, but it would be a lot of work and we're focusing our energy elsewhere.

We don't want to have an option to track extra fields in the database because then it becomes harder for developers to extend those page types with customised functionality. A key design decision of SilverStripe is that we ensure that websites developed with it are extensible and maintainable as a software project. This does mean that we lack certain GUI-based features such as a page type editor, but that's a trade-off we have had to make.

Avatar
biapar

Forum Moderator, 435 Posts

27 June 2009 at 1:04am

I agree that without using predefined or wizard GUI , we have more funny, power and control and with a simple notepad , we are able to write/modified a class page.
I understand that to add new fields in a SS page ... I must add array and cmsfield codes... and for creating a new type of page template , I must extend a page base class... ( is it ok ? ) -:))

Avatar
CrazyCoders

Community Member, 32 Posts

27 June 2009 at 1:49am

Indeed, creating a page type is as simple as copying this code:

<?php

class NewPageName extends Page {
   
   public static $db = array(
   );
   
   public static $has_one = array(
   );
   
}

class NewPageName_Controller extends Page_Controller {
   
}

?>

Into a new file:

1. Copy the previous code
2. Change the name of the created class (NewPageName for something else)
3. Save the file under the name of the class (Case sensitive)
4. Upload
5. Run /dev/build
6. Reload CMS and you are done, you have a new page type

If you want more customized behavior then you need to read the tutorials or find a programmer willing to help you (This is outside the scope of this forum)

Cheers

Avatar
biapar

Forum Moderator, 435 Posts

30 June 2009 at 9:24pm

Thank you.....

And for creating new TAB in admin Area?