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.

Customising the CMS /

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

custom template


Go to End


4 Posts   1273 Views

Avatar
servalman

Community Member, 211 Posts

8 October 2009 at 4:55am

Hi

When I want to create new template I always extend Page, wich goes with a "content " tab on the HTML editor.
I also know how to create another Tab by insterting a new html field in my template.

My problem is now the following :

I Need to create another template with a content Tab but I don't want it to be the "original" content tab but a spécific one.

How can I do that without rmoving it from Page wich I presume would remove it everywhere

Thanks for any clue

T

Avatar
dalesaurus

Community Member, 283 Posts

8 October 2009 at 4:38pm

The easiest solution would be to extend page, which would create a whole corresponding template (or Layout) and you can customize the contents of the DataObject.

This will not affect your existing Page types and you can add any kind of data types to the $db array to suit your needs.

Read up here, starting with the Adding Date and Author Fields
http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site

Avatar
servalman

Community Member, 211 Posts

8 October 2009 at 7:51pm

Thanks

BUt that keeps the content tab always does it ?

T

Avatar
dalesaurus

Community Member, 283 Posts

9 October 2009 at 5:41am

Yes, but it will be a separate table that will not interfere with your existing pages.

Content is merely an DataObject $db variable named Content of type HTMLText ('Content' => 'HTMLText'). Whenever you throw a type HTMLText to the CMS it will give you the WYSIWYG editor.

If you don't want one, create a new Page type and controller that extends SiteTree instead of Page, then you can start from scratch.

If that sounds too complicated, just do the following:

function getCMSFields() {
	$fields = parent::getCMSFields();
	$fields->removeByName('Content');
	return $fields;
}