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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

[Solved] Silverstripe 3.5.3 renderwith in Index() of extended Page_Controller. Bug?


Go to End


3 Posts   338 Views

Avatar
KatB

Community Member, 105 Posts

1 March 2017 at 1:51pm

class StructuredProduct_Controller extends Page_Controller {

function init(){
parent::init();
}

function index() {
return $this->renderWith(Array("ProductPageRDFa", "PageRFDa"));
}

}

For the most part, this works. Unexpected result: extra two blank lines above the output:

"

<?xml version="1.0" encoding="UTF-8"?>
"

The template does not contain these blank lines. I did try to use the $allowed_actions array -- but it did not produce the desired result.

Blah blah blah:
I have installed this version of Silverstripe on my local computer for testing. I am trying to test using RDFa on a subsection of the site, and thus need a different doctype from the rest of the site. I thought I could use renderwith() for that purpose. For the most part, it works well, with the exception of these two blank lines.

Are these two blank lines a bug? Is it something I've done? How do I get rid of them?
Thanks!

Avatar
KatB

Community Member, 105 Posts

1 March 2017 at 2:50pm

Incremental improvements!

1. Changed the theme to my own basic simple one.
2. Chased down extra white space in my custom PHP to remove trailing lines as per (https://www.silverstripe.org/community/forums/themes-2/show/23379)

Still left with one extra empty blank line above the specific renderwith() custom template.

Avatar
KatB

Community Member, 105 Posts

1 March 2017 at 3:25pm

Alright! Problem solvered!

Continued on with the code clean up at the bottom of custom PHP files (removing trailing white space) and the entire issue is fixed!

Believe it or not, I have spent a considerable amount of time searching for this answer, on Google, in Silverstripe code, etc. If I had known that the answer would appear as soon as I decided to accept looking silly on the Silverstripe forum, I would have posted sooner!

I will leave this thread as it may help with Google search rankings for the next person who has the same problem.