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.

General Questions /

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

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

[Solved] Prevent automatic population of head/body tag


Go to End


3 Posts   1084 Views

Avatar
esakrielaart

Community Member, 59 Posts

9 January 2014 at 5:41am

Hi all,

I have the problem, in which Silverstripe is just trying to do more than I need. The situation: a forTemplate() method is called on a DataObject, using a template, as

function forTemplate() {
return $this->renderWith('template');
}

The result of this rendering will be written to a XML file, which is working fine. However, in the template.ss, I have included an <head> and <body> section, and silverstripe automatically populates these with its requirements from the CMS (javascripts, CSS). Can I prevent this some how (other than adding whitespaces to the tag names).

Kinds regards!
Maurice

Avatar
kinglozzer

Community Member, 187 Posts

9 January 2014 at 5:46am

Hi Maurice,

If I understand correctly, you should just be able to add the following code snippet before your call to renderWith();:

Requirements::clear();

Loz

Avatar
esakrielaart

Community Member, 59 Posts

9 January 2014 at 5:50am

Hi there,

you're absolutely right! This solved my problem, and just that fast :-)

Thanks,
Maurice