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   1564 Views

Avatar
macka

Community Member, 33 Posts

6 June 2011 at 10:57pm

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

Forum Moderator, 5513 Posts

7 June 2011 at 3:41pm

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

Community Member, 33 Posts

7 June 2011 at 3:49pm

Thanks Will,
I'll give that a try.

Grant

Avatar
macka

Community Member, 33 Posts

12 June 2011 at 11:18pm

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

Forum Moderator, 5513 Posts

13 June 2011 at 2:53pm

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

Avatar
macka

Community Member, 33 Posts

14 June 2011 at 10:16pm

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

Grant

Avatar
Willr

Forum Moderator, 5513 Posts

15 June 2011 at 7:24pm

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

Community Member, 33 Posts

15 June 2011 at 11:07pm

Thanks Will, worked nicely.

Cheers
Grant