21294 Posts in 5734 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » How to convert URLs from /extending-silverstripe-overview/ to correct form?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1424 Views |
-
How to convert URLs from [sitetree_link id=17] to correct form?

30 March 2011 at 3:55am
Hi to all
I have a function in my controller class that returns html text containig URL like [sitetree_link id=17].
When I call that function from a template file ".ss" the URL still remain of the form [sitetree_link id=17] and don't get converted in the correct form.Is there something to do to get URLs converted as usual?
Thank you.
-
Re: How to convert URLs from [sitetree_link id=17] to correct form?

30 March 2011 at 10:42am
hmmm I've seen this in an old version of silverstripe when I create links in the tinymce, but I'm confused as to why you'd return this from a controller function. Surely you'd return $page->Link() and that would be an actually url?
I may have misunderstood, so it might help if you post the controller function code...
-
Re: How to convert URLs from [sitetree_link id=17] to correct form?

30 March 2011 at 6:14pm
The [sitetee_link] is a ShortCode. By default ShortCodes are parsed when you output HTMLText fields to your template. If you are altering your HTMLTextField in your controller, make sure you return the result as an HTMLText field
// This code will FAIL - show [sitetree..]
function Foo() {
return $this->Content;
}// This code will WORK - translate showcodes
function Foo() {
return DBField::create('HTMLText', $this->Content);
} -
Re: How to convert URLs from [sitetree_link id=17] to correct form?

1 April 2011 at 2:10am
The line:
return DBField::create('HTMLText', $this->Content);
is what I was looking for, thank Willr and Swaiba for the answers.
-
Re: How to convert URLs from [sitetree_link id=17] to correct form?

18 August 2011 at 1:00am
I'll second that. Thanks Willr - you just saved me from what otherwise may have been hours of frustration. +1 kudo's.
| 1424 Views | ||
|
Page:
1
|
Go to Top |



