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.

Template Questions

Default Silverstripe shortcodes failing to parse


Reply

2 Posts   1268 Views

Avatar
ezero

6 December 2010 at 10:34am (Last edited: 6 December 2010 10:51am), Community Member, 7 Posts

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

6 December 2010 at 7:59pm Forum Moderator, 5511 Posts

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)