Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » MAYDAY!! Short Code problem heeeelllllllp

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

Page: 1
Go to End
Author Topic: 1036 Views
  • Pix
    Avatar
    Community Member
    131 Posts

    MAYDAY!! Short Code problem heeeelllllllp Link to this post

    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));
    }

    In SendForm.ss:
    <% if SendSuccess %>
          <h2>Your Email has been sent!</h2>
       <% else %>
          <h2>Form goes here</h2>
          $HTMLeMailForm
    <% 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!

    Thanks!

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: MAYDAY!! Short Code problem heeeelllllllp Link to this post

    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.

  • stallain
    Avatar
    Community Member
    61 Posts

    Re: MAYDAY!! Short Code problem heeeelllllllp Link to this post

    @Pix
    How about trying this :

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

    1036 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.