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.

Content Editor Discussions

Forum for content editors and CMS users.

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

parsing content before rendering


Reply

8 Posts   1483 Views

Avatar
macka

6 June 2011 at 10:57pm Community Member, 24 Posts

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

Avatar
Willr

7 June 2011 at 3:41pm Forum Moderator, 5511 Posts

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/

Avatar
macka

7 June 2011 at 3:49pm Community Member, 24 Posts

Thanks Will,
I'll give that a try.

Grant

Avatar
macka

12 June 2011 at 11:18pm Community Member, 24 Posts

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

Avatar
Willr

13 June 2011 at 2:53pm Forum Moderator, 5511 Posts

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

Avatar
macka

14 June 2011 at 10:16pm Community Member, 24 Posts

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

Grant

Avatar
Willr

15 June 2011 at 7:24pm Forum Moderator, 5511 Posts

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

Avatar
macka

15 June 2011 at 11:07pm Community Member, 24 Posts

Thanks Will, worked nicely.

Cheers
Grant