Jump to:

517 Posts in 247 Topics by 260 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » parsing content before rendering

Forum for content editors and CMS users.

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

Page: 1
Go to End
Author Topic: 1437 Views
  • macka
    Avatar
    Community Member
    22 Posts

    parsing content before rendering Link to this post

    Hi there,
    Still all new here.. so go gently...

    Could someone give me a hint on parsing content before i render it?
    I would like to have in the content editor something like {specificTag} and then as it's rendered the actual value to be replaced using another function.

    This is so i can have the user design their table in the content editor and then have it replaced upon render.

    Ta.
    Grant

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: parsing content before rendering Link to this post

    For this I would suggest using short codes. SSBits has a good tutorial on this - http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/

  • macka
    Avatar
    Community Member
    22 Posts

    Re: parsing content before rendering Link to this post

    Thanks Will,
    I'll give that a try.

    Grant

  • macka
    Avatar
    Community Member
    22 Posts

    Re: parsing content before rendering Link to this post

    Hi Will,
    So i've given that tutorial a go... Am i correct in assuming with short codes you can only parse one variable at a time?
    IE, i have a table that looks like

    Reading number   [Weather index]
    Date Taken   [Weather storedDate]

    So when i try to import the data into it using the short codes method, i get something that looks like
    Reading number   1548 2011-06-12 22:31:10
    Date Taken   1548 2011-06-12 22:31:10

    Thanks
    Grant

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: parsing content before rendering Link to this post

    Sounds like from your example you would need 2 short codes. One for the reading number, one for the stored date.

  • macka
    Avatar
    Community Member
    22 Posts

    Re: parsing content before rendering Link to this post

    I thought this, it's just that i would need 14 of them then.

    Grant

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: parsing content before rendering Link to this post

    Could pass it as an argument then do a switch in your short code..

    [Weather output=storedIndex]

    ...
    public static function YourShortCodeHandler($arguments,$caption= null,$parser = null) {
    switch ($arguments['output']) {
    case 'storedIndex':
    // foo
    case 'index'
    // bar
    }
    ..
    }

  • macka
    Avatar
    Community Member
    22 Posts

    Re: parsing content before rendering Link to this post

    Thanks Will, worked nicely.

    Cheers
    Grant

    1437 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.