Jump to:

23361 Posts in 18124 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » [Solved] $AbsoluteBaseURL or $BaseHref have CRLF appended

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

Page: 1
Go to End
Author Topic: 738 Views
  • tazzydemon
    Avatar
    Community Member
    120 Posts

    [Solved] $AbsoluteBaseURL or $BaseHref have CRLF appended Link to this post

    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
          );
       }

    738 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.