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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Builder module


Go to End


2 Posts   1998 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 December 2008 at 5:21am

Edited: 30/12/2008 5:34am

Just something I came up with in about an hour just for fun. If you're anything like me, you find it tedious to create new PHP classes with the same structure and variables every single time you want a new page type. This Builder module allows you to do that from the URL like this:

http://www.mysite.com/builder/MyNewClass/ParentClass/StartingTemplate

Where "MyNewClass" is the name of the page type you want to create, "ParentClass" is just that -- usually Page, and "StartingTemplate" is the Layout you want to duplicate to get your template started. So in this example:

http://www.mysite.com/builder/PortfolioPage/Page/Page

You will get a new file PortfolioPage.php in your mysite/code folder with the model, getCMSFields(), and controller already built out for you to customize, and you'll also get a PortfolioPage.ss in your mysite/templates/Layout folder that is a clone of Page.ss, meant to be customized.

Default values for the last two parameters are "Page." So the above can actually be achieved with this:

http://www.mysite.com/builder/PortfolioPage

Automatically redirects to a db/build.

To set permissions, use Bulder::set_file_permissions($octet) in builder/_config.php. e.g. Builder::set_file_permissions(0755) (default value). $octet must be an integer.

Anyway, I find this is a huge timesaver when I'm starting a project. Hopefully someone else will. Enjoy!

Attached Files
Avatar
Carbon Crayon

Community Member, 598 Posts

30 December 2008 at 12:50pm

nice one uncle cheese, thats a great idea!

As simple as it is it, it always seems like such a chore to make a new page type, especially when working online (when using aptanas ftp at least).

SS development gets even easier ;)