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

MAYDAY!! Short Code problem heeeelllllllp


3 Posts   1091 Views


25 November 2011 at 8:34am (Last edited: 25 November 2011 8:35am), Community Member, 145 Posts

I am trying to get a form embedded in my page through a short code. It was working just fine and showing up until I tried doing it with a template, and now NO form, but the the other stuff in the template shows up ("Form goes here" text)!

In Page.php:
public static function EmailFormShortCodeHandler($arguments, $content = null, $parser = null) {
    $customise = array();
    $customise['contactme'] = 'test';
    $template = new SSViewer('SendForm');
    return $template->process(new ArrayData($customise));

<% if SendSuccess %>
      <h2>Your Email has been sent!</h2>
   <% else %>
      <h2>Form goes here</h2>
<% end_if %>

The function to generate the form is in Page_Controller, when I called it directly from the short code it showed up, like this:
public static function EmailFormShortCodeHandler($arguments, $content = null, $parser = null) {
$current = Controller::curr();
return $current->HTMLeMailForm()->forTemplate();

But I really need to use a template to show the form, any suggestions please heeeeeeeeelllllllp!


Ryan M.

26 November 2011 at 6:55pm Community Member, 309 Posts

A shortcode wouldn't work in a .ss template. If the function HTMLeMailForm is present in your Page file, it should get called with $HTMLeMailField.


28 November 2011 at 2:13pm Community Member, 61 Posts

How about trying this :

static function EmailFormShortCodeHandler(){
$current = Controller::curr();
return $current->renderWith('SendForm');