Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2010-05-04] Consistently use ShortcodeParser in Text/HTMLText value getters (breaking [sitetreelink_id] in SiteTree.Content) #1381

Closed
silverstripe-issues opened this issue Apr 3, 2013 · 4 comments

Comments

@silverstripe-issues
Copy link

created by: @chillu (ischommer)
created at: 2010-05-04
original ticket: http://open.silverstripe.org/ticket/5535


At the moment the ShortcodeParser just applies in HTMLText/HTMLVarchar->forTemplate(). This getter is not used when further processing the output or using an alternative, e.g. through FirstParagraph().

SHortcodes should be respected in all those getters, specifically:

  • StringField->forTemplate() ?
  • Varchar->LimitCharacters()
  • Text->FirstParagraph(), LimitWordCount(), LimitWordCountXML(), LimitSentences(), FirstSentence(), Summary(), BigSummary(), ContextSummary()
  • HTMLText->LimitCharacters(), Summary, FirstSentence()

Also, its unclear why its limited to HTML fields only - text fields should be able to have shortcodes as well, right? Best example being the bbcode style enforced on BlogEntry.Content.

@simonwelsh simonwelsh added this to the 3.2 milestone Mar 15, 2014
@tractorcow
Copy link
Contributor

This issue hasn't been touched for about 2 years but I'd like to elevate this as a bug impacting 3.1. At the very least, HTMLText should override any method that doesn't respect shortcodes with an appropriate replacement.

With the recent work on updating the blog module we should look at improving framework's support for these methods.

@tractorcow
Copy link
Contributor

Will try to address in #5653

@dhensby
Copy link
Contributor

dhensby commented Jun 8, 2016

Context: At the moment the shortcodes are parsed only on HTMLText objects so a plain text object cannot have shortcodes parsed. HTMLText parses the shortcodes in the forTemplate method so it happens at the last possible moment (just before being output in the template) rather than when the value is set or get. Each have their advantages and pitfalls.

What is certain is that the shortcodes need to be parsed before any content-type encoding or other manipulation of the value is done.

I think adding the parser to thesetValue method makes instantiation of a HTMLText object too expensive, putting it on the getValue is inefficient (multiple runs) or too fragile to cache.

For now, it looks like @tractorcow's suggestion of overriding each of the functions (XML, Summary, etc) and having them parse the codes FIRST and then escape is best.

tractorcow pushed a commit to tractorcow/silverstripe-framework that referenced this issue Jun 15, 2016
tractorcow pushed a commit to tractorcow/silverstripe-framework that referenced this issue Jun 17, 2016
tractorcow pushed a commit to tractorcow/silverstripe-framework that referenced this issue Jun 17, 2016
tractorcow pushed a commit to tractorcow/silverstripe-framework that referenced this issue Jun 17, 2016
tractorcow pushed a commit to tractorcow/silverstripe-framework that referenced this issue Jun 17, 2016
tractorcow pushed a commit to tractorcow/silverstripe-framework that referenced this issue Jul 12, 2016
@tractorcow
Copy link
Contributor

Fixed with #5653 :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants