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.

Template Questions /

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

Default Silverstripe shortcodes failing to parse


Go to End


2 Posts   2412 Views

Avatar
ezero

Community Member, 7 Posts

6 December 2010 at 10:34am

Edited: 06/12/2010 10:51am

In my search results (Page_results.ss) I have got $Content.FirstParagraph.RAW

The problem is that I am seeing [[sitetree_link id=9]] on the results page, instead of the link. Is it some how failing to parse short codes? Or something I might have missed in the configuration?

Could be a bug in Silverstripe but I have not attempted to replicate in another default install.

Please advise.

Thanks

---------------------------------------------------------------------------------------------------------------------------------

Just to answer my question above (thanks to Willr)

First thing I was doing wrong is use .RAW on the content which bypasses shortcodes.

Secondly, he suggested alternative to use Summary(100) instead which still doesn't turn links in to links but atleast it doesn't show [[sitetree_link_id=9]] in the results

Lastly, you can also write a custom function and stack on top of $Content.CustomFunction to get the desired effect.

Avatar
Willr

Forum Moderator, 5523 Posts

6 December 2010 at 7:59pm

The code which I sent through (in case anyone else wants it) is available - http://pastie.org/1350494.

For shortcodes to work the field must be a HTMLText field. Sadly all the Text functions don't return that type of object (hence the casting in that example)