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

baseURL in literalField


Go to End


2 Posts   598 Views

Avatar
merrick_sd

Community Member, 99 Posts

23 August 2013 at 11:55pm

what should it be to include the BaseURL in some text in the CMS like on a literal field

$fields->addFieldToTab("Root.Main", new LiteralField (
"literalfield",
"<p>Download Example Banner <a href=\"/".Director::absoluteBaseURL()."/BannerModule/images/examples/770x314.zip\" target=\"_blank\" >Example Banner Image 770 x 314px [zip]</a></p>"
));

this come out whithe the domainname twice!!!

http://dev.mydomain.co.uk/http://dev.mydomain.co.uk//lBannerModule/images/examples/770x314.zip

Avatar
merrick_sd

Community Member, 99 Posts

24 August 2013 at 12:01am

solution

$fields->addFieldToTab("Root.Main", new LiteralField (
"literalfield",
"<p>Download Example Banner <a href=\"/BannerModule/images/examples/770x314.zip\" target=\"_blank\" >Example Banner Image 770 x 314px [zip]</a></p>"
));