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.

General Questions

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

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

Calling a "command" from within the page content?


Reply

3 Posts   416 Views

Avatar
LinseyM

9 March 2013 at 4:09am (Last edited: 9 March 2013 4:09am), Community Member, 99 Posts

Hi all!

How would I go about calling a command (tag?) from within the WYSIWYG editor, in order to place a CMS menu within the page content. EG, in the way that placing "$UserDefinedForm" within the page content editor places the form where you want it to go, and lets you have text above and below it?

I have a menu within the template that currently sits below the $Content tag, but i'd like to be able to call it from within the actual content so that I can decide precisely where it goes, eg something like:

-----
This is my heading

Some content

$CallMenu

Some more content
-----

Hope this makes sense - struggling to explain it!

Cheers, L x

Avatar
Willr

9 March 2013 at 12:00pm Forum Moderator, 5511 Posts

Userforms does a basic str_replace on the content (https://github.com/silverstripe/silverstripe-userforms/blob/master/code/model/UserDefinedForm.php#L385) but a better method would be to use ShortCodes.

http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/

Avatar
LinseyM

9 March 2013 at 12:29pm Community Member, 99 Posts

Brilliant thanks Will! I just didn't know what terms to search for to find this info. Short codes will do exactly what I need, but the str_replace is good to be aware of too. Cheers :-)