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

how to start dev/build from cms after creation of a new Class (PageType)


8 Posts   1136 Views


21 March 2011 at 9:10am Community Member, 42 Posts


I'm creating new Classes (PageTypes) in the cms and want to rebuild the db after saving the new class to mysite/code to
publish the new class.
The Classname-Field of the SiteTree-Tables needs to be updated to add the new PageType-Class

I foud DB::beginSchemaUpdate() but I dont know if it does the right action and if yes, how to do it ??

THanks in advance for any advice



21 March 2011 at 1:36pm Community Member, 133 Posts

Don't you just want to do a dev/build?

If so then just type:



21 March 2011 at 2:40pm Community Member, 90 Posts

yeah.. Like ampedup said..
Try the default silverstripe db re-build url.



21 March 2011 at 11:52pm Community Member, 42 Posts

hi again,..
I'm creating the classes on the fly in one of my onAfterWrite-Events in ModelAdmin and need
to update SiteTree /live/version without typing any url. It has to happen in the background...


22 March 2011 at 12:48am Community Member, 133 Posts

Hi Lukin,

Why do you want to create classes on the fly from the CMS?


22 March 2011 at 1:17am Community Member, 42 Posts

well :)

I'm building some kind of catalogue which is organized in serveral categories an subcategories. These categories are managed in a modeladmin. The catalogue itself is managed in the Pages - sitetree, like normal pages. Now if the user adds a new category in modeladmin, I need to create a pagetype (pagetype-class) wich represents the new category in sitetree... Although I'm creating a new ss-template for each category...
This might be a bit complicate but seems to be the most userfriendly solution for my needs, ...


22 March 2011 at 11:23am Community Member, 133 Posts


I would have the categories as just a field in your page. Looking at your description there are going to be no structural differences between the pages that have different categories. In that case there is no need to create new page types. Just have a dropdown to select which category the object is. This dropdown can still be generated from a list you create in modeladmin.

I don't think it's possible to create new page types on the fly like this. To the best of my knowledge, you need to physically write the php code to define the classes you want.


22 March 2011 at 12:45pm (Last edited: 22 March 2011 1:08pm), Community Member, 42 Posts


well, there are some differences,.. subcat of cat musn't show all pages of cat and sub1 of cat has diffrent pages than sub2 of cat...
subsub extends sub extends cat....

I thought about the dropdownsolution aswell, but I want to do it autmoatic, so the user doesn't have to configure which type of pages he needs to create.


1. Creating new Categroy in ModelAdmin ... onAfterWrite:
2. Writing new Class-File with the name of the new category to mysite/code
3. [unsolved] Rebuilding database or better only rebuilding the sitetree-tables
4. Creating new Page with my new PageType into SiteTree

With the target to get these dataobject 'multilevel-structure' displayed as pages( and subpages, or categories/subcategories) in SiteTree

hope you got me....

I'm not very familiar to write in english :)