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] $AbsoluteBaseURL or $BaseHref have CRLF appended


Go to End


3765 Views

Avatar
tazzydemon

Community Member, 135 Posts

7 March 2013 at 1:27pm

Edited: 08/03/2013 5:34pm

I have been trying to make the ss3 dev site I am running in a subdirectory have correct template references by using this in my templates:

<script src="{$BaseHref?}{$ThemeDir?}/blahblah.js"></script>

or more correctly now:

<script src="{$AbsoluteBaseURL}{$ThemeDir?}/blahblah.js"></script>

However both fail because a PHP_EOL is being appended to the URL thus breaking the line and therefore the link.

I thought I had traced this to function Text__finalise() in SSTemplateParser.php.inc but this appears not to be the case. I thus far have failed to find the source. Note that the $ThemeDir? does not have the CRLF appended and the output directly from Director:absoluteBaseURL() seems fine.

Interesting that it's CRLF appended because I am testing on Windoze but serving from linux. The files are linux correct as far as I am aware.

Needless to say I have scoured the place for \r\n as well.

I have put this in Trac too.

Stop press. I tracked it to the casting in SSviewer using default casting (HTMLText) for the array in get_template_global_variables() in Director.php. I believe this should be 'Text' and I have altered the array in Director.php as follows:


	public static function get_template_global_variables() {
		return array(
			'absoluteBaseURL' => array('method' => 'absoluteBaseURL', 'casting' => 'Text'),
			'baseURL'  => array('method' => 'baseURL', 'casting' => 'Text'),
			'is_ajax',
			'isAjax' => 'is_ajax',
			'BaseHref' => 'absoluteBaseURL',    //@deprecated 3.0
		);
	}