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

[Solved] Prevent automatic population of head/body tag


Reply


3 Posts   211 Views

Avatar
esakrielaart

Community Member, 56 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, 166 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, 56 Posts

9 January 2014 at 5:50am

Hi there,

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

Thanks,
Maurice