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

[SOLVED] 2.4 -> 3.1 - How to parse fields for template includes


Go to End


4 Posts   1713 Views

Avatar
Double-A-Ron

Community Member, 607 Posts

24 March 2014 at 7:37pm

So I have a HTMLText field on an object that is plonked in an include. This field often contains an internal link like [sitetree_link id=113]. I found if I put that direct into the template, the link shortcode is not parsed.

So in 2.4 I did this, which worked perfectly:

function GetCleanInclusions() {
		return DBField::create('HTMLText', $this->TourInclusions);
	}

In 3.x, DBField is abstract and can't be instantiated. I've had a dig around, mainly in the HTMLText model class itself, and I can't find the equivalent for the latest SS.

Just like 2.4, returning the field direct results in the include displaying the text, but the link is still un parsed.

Cheers

Avatar
(deleted)

Community Member, 473 Posts

24 March 2014 at 9:15pm

You use DBField::create_field instead of DBField::create (there's been a move away from overloading create())

Avatar
Double-A-Ron

Community Member, 607 Posts

24 March 2014 at 9:30pm

Perfect Simon. Thank you.

Avatar
Over-Thinker

Community Member, 7 Posts

16 July 2014 at 2:08am

Hi Guys,

I've got the same issue.

Could you give a clear walkthrough where the file is located that I need to edit please?

I just can't seem to figure this one out.

Thanks for your help!!