Jump to:

21309 Posts in 5738 Topics by 2603 members

General Questions

SilverStripe Forums » General Questions » Using shortcodes within DataObjects

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

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 152 Views
  • Harley
    Avatar
    Community Member
    145 Posts

    Using shortcodes within DataObjects Link to this post

    I want to reuse some shortcodes I have created, however I have quite a number of ‘Page types’ that use specific DataObjects and I don’t want to have to duplicate my shortcode functions for all of these.

    Does anyone know if there is there a way to define a shortcode function in one place and then call it in for each DataObject?

    Thanks

    Peter

  • martimiz
    Avatar
    Forum Moderator
    877 Posts

    Re: Using shortcodes within DataObjects Link to this post

    Hi Harley,

    I'm not quite sure if I understand you correctly - maybe you could give a small example of what you mean?

    Anyway, to create different options for one and the same shortcode, you could maybe let the shortcodhandler call a Page method, and then override that method in your different Page classes. Or have the shortcode handler check it's Page classname, and act accordingly. Or use some parameter in your shortcode, if all else fails?

    152 Views
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.