Shortcodes in C5?
Permalink 1 user found helpful
Hi,
A client came to me the other day and asked:
'why do I have to insert a YouTube block in-between two content blocks if I want a video to appear? That means if i want to edit content either side of it, I have double the workload (or more) if I have several YouTube and Content blocks together?'
So I told her that you can also insert YT vids via the WYSIWYG editor (and HTML editor), but she found that difficult so I wondered whether shortcodes (like in Wordpress) would be possible in C5?
That way, I could write a function that lets her do this:
[youtube url="http://www.youtube.com/?v=a7shnf"]
And she could place a video where she wants within text and move it easily.
I think this is great feature of WP, is something like that possible in C5?
Thanks
osu
A client came to me the other day and asked:
'why do I have to insert a YouTube block in-between two content blocks if I want a video to appear? That means if i want to edit content either side of it, I have double the workload (or more) if I have several YouTube and Content blocks together?'
So I told her that you can also insert YT vids via the WYSIWYG editor (and HTML editor), but she found that difficult so I wondered whether shortcodes (like in Wordpress) would be possible in C5?
That way, I could write a function that lets her do this:
[youtube url="http://www.youtube.com/?v=a7shnf"]
And she could place a video where she wants within text and move it easily.
I think this is great feature of WP, is something like that possible in C5?
Thanks
osu
Thanks jordanlev,
That works for me.
That works for me.
Am wondering the same myself as I'm with a day-to-day client who has a big site (several thousand pages) in Wordpress which 'seemed like a great choice at the time' (I'm encouraging them to move to C5).
Coding up a [shortcode] thingy though would, imho, introduce a security weakness into C5 although it's a useful thing to be able to do.
Perhaps creating a special view for a block which could parse shortcodes could be a halfway house.
I need to find a solution to this myself, anyway, so if I do I'll make sure the C5 community benefits from anything useful I create :o)
G
Coding up a [shortcode] thingy though would, imho, introduce a security weakness into C5 although it's a useful thing to be able to do.
Perhaps creating a special view for a block which could parse shortcodes could be a halfway house.
I need to find a solution to this myself, anyway, so if I do I'll make sure the C5 community benefits from anything useful I create :o)
G
Anyway, to make this work for your client you could override the Content block controller by copying the "controller.php" file out of concrete/blocks/content into a new folder at blocks/content (note that you're copying it out of the "concrete" folder into the plain old "blocks" folder in your site's root directory).
Now in that new controller.php file, find this code:
and modify it to something like this:
I'm using a regular expression to pull out a string that's formatted the way you stated -- you may need to play around with this to get it working just the way you want.
HTH!
-Jordan