Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Custom shortcodes aren't parsed when using a custom parser?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 590 Views
  • josh.gross
    Community Member
    8 Posts

    Custom shortcodes aren't parsed when using a custom parser? Link to this post

    I'm playing around with custom shortcodes, and creating custom parsers, and the two don't seem to play well together.

    I want to create a custom parser that will parse the content on each page, and, for example, find every link that leads to a PDF, and automatically add some text to the end of the link that says something like "(PDF, XX kB)". Since I want this to happen to every link, I figure it's best to use a custom parser, rather than a shortcode. (Is that correct?)

    However, I also want to be able to use shortcodes on the same page. I'm working on a shortcode that will display an automatically generated list of all the subheadings on a page with a same-page link to each heading, and I want the person using the CMS to be able to place this list anywhere on a page, so I'm guessing that would have to be done with a shortcode and not a parser?

    So I've worked out how to create a custom parser and apply it to my content using something like "$Content.Parse(LinkParser)" instead of "$Content" in my template file, but then the shortcodes aren't parsed. They only get parsed if I use "$Content".

    Is there a way to get my content to be parsed by my custom parser, and to be parsed by the regular parser that does the shortcodes? It doesn't matter to me in which order the parsers are applied - just as long as both of them are applied.

    Is that possible?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.