Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

Is it at all possible to have a text input or area field in which we could enter EE code to be processed by the template.

For example, if we could have a text area called "Advanced Functionality" and within this write things like

 {sn_contact-form}

Right in the channel entry, and then in our template call...

{advanced_functionality}

then that could be valuable in some instances.

Is this too far down the parse order to happen? Or does anybody know of a solution?

share|improve this question
    
To clarify: You want a user to be able to submit EE tags and have the parse-engine parse that as if its a template? –  fideloper Nov 26 '12 at 22:16
    
That's correct. –  Andrew Fairlie Nov 26 '12 at 22:16
add comment

4 Answers 4

You could do this combining Stash and the allow_eecode plugin. http://www.tyssendesign.com.au/articles/cms/more-stash-examples/ has a great example of the functionality you're trying to achieve (example 1 wp shortcode).

For stash see https://github.com/croxton/Stash, allow_eecode http://devot-ee.com/add-ons/allow-ee-code

share|improve this answer
    
Perfect. Alow EE Code is just what I had in mind. Thanks @erwinheiser –  Andrew Fairlie Nov 26 '12 at 22:24
    
no need for Allow EE Code plugin - you can get Stash to parse the snippet as in my example –  James Smith Nov 26 '12 at 22:27
    
I feel that Allow EE Code is very unsafe unless you know for a fact that only you will ever be entering content. If you are building a site for an end-client you should never use this, as it would allow whoever they give access to the control panel to do basically whatever they want to your site and database through the use of malicious template code. –  Isaac Raway Nov 26 '12 at 22:27
    
Good points well made. Unaccepted this answer (sorry!) because of the points raised. –  Andrew Fairlie Nov 26 '12 at 22:29
    
I think this is a really cool option, it's just too dangerous to use on sites that are edited by end-users. –  Isaac Raway Nov 26 '12 at 22:30
add comment

I have a new module called Shortcode coming out soon which enables this type of thing. It is a bit more restrictive in that it only allows tags that have been setup for it to be parsed since it'd be very unsafe to allow for open ended template code to be entered as content. That said, it's trivial to add new Shortcodes to the module with just a few lines of code.

For instance, you could easily insert a ProForm form using this tag:

[form form_name="application_form"]

Let me know if you'd like a demo by posting in the Shortcode forum.

share|improve this answer
    
Sounds great. I marked @erwinheiser's as the accepted answer as it can be used today by anybody looking at this question but I'll definitely check out Shortcode when I get a few. –  Andrew Fairlie Nov 26 '12 at 22:28
    
Yep with the caveats I just posted on the other answers, they are both pretty good options that you can use now. Let me know if you want a demo of Shortcode, I'll send it over. –  Isaac Raway Nov 26 '12 at 22:28
    
cool, was unaware of this add-on. Keeping an eye on it! –  erwinheiser Nov 26 '12 at 22:30
add comment

Stash, yet again(!), is the answer:

{exp:channel:entries}
    {exp:stash:parse process="end"}
        {advanced_functionality}
    {/exp:stash:parse}
{/exp:channel:entries}

... this does the trick for parsing snippets

Then if you want to get more creative with custom shortcodes instead of snippets, you'd use stash:set first like this:

{exp:stash:set name="shortcode_inside_field" type="snippet"}
    <p>Hi there! It's important to set type="snippet" so that {shortcode_inside_field} will get automatically replaced with this sentence by the stash:parse tag later on.</p>
    ... now run all kinds of complicated EE tags here to generate the content of the shortcode (be sure to add parse_tags="yes") ....
{/exp:stash:set}

{exp:channel:entries}
    {exp:stash:parse process="end"}
        {advanced_functionality}                
    {/exp:stash:parse}
{/exp:channel:entries}
share|improve this answer
    
We did this extensively in one of the sites that I worked on, it's a good method if you only have a handful of tags that need to be inserted and they do not need to take parameters. Otherwise, see my Shortcode answer. –  Isaac Raway Nov 26 '12 at 22:27
    
Could you give me a quick overview about what this is doing? In the first portion you seem to be setting the stash partial, and 'getting' it further on. What is the reason for this? Shouldn't this just be part of {advanced_functionality}? –  Andrew Fairlie Nov 26 '12 at 22:31
    
Sorry my first response was a little premature... (I've spent over a year doing it this way using the old String plugin, which has an :output method that makes this easy)... However the latest (dev) branch of Stash includes the parse method which means (since it's a snippet) you can do it as shown. –  James Smith Nov 26 '12 at 23:21
add comment

Hmm, good question. I dont think this would be possible with snippets, as they are always parsed too early.

By the sounds of things this is basically what the Shortcodes addon will offer - though that isn't publicly available yet - maybe @IsaacRaway can chip in and let us know?

share|improve this answer
    
Yep, posted an answer for Shortcode. If anyone wants a demo copy they can post in the forum for the module and I'll send it over. –  Isaac Raway Nov 26 '12 at 22:34
    
Damn, you beat me to it :) –  Tom Davies Nov 26 '12 at 22:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.