Jump to:

23367 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » Populate Data? How Works?

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: 1271 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Populate Data? How Works? Link to this post

    I wrote:

    $templateData = array(
    'WelcomeMessage' => $welcomeMsg, // Accessible in template via $WelcomeMessage
    'VarFirstName' => $SignupFirst,
    'VarEmail' => $SignupEmailAddress,
    'VarPassword' => $SignupPwd,
    'VarSurname' => $SignupSurn
    );
    $email->populateTemplate($templateData);

    and my SignUp.ss template is:

    <h3>Hi, $VarFirstName $VarSurname.</h3>
    <br/>

    <p>$WelcomeMessage</p>

    <ul>
    <li><strong>Email:</strong>$VarEmail</li>
    <li><strong>Password:</strong>$VarPassword</li>

    but my template vars on signup.ss are not populated. Only $WelcomeMessage. Why?

  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: Populate Data? How Works? Link to this post

    What about making sure the values are actually passed into $templateData?

    $templateData = array(
    'WelcomeMessage' => $welcomeMsg, // Accessible in template via $WelcomeMessage
    'VarFirstName' => $SignupFirst,
    'VarEmail' => $SignupEmailAddress,
    'VarPassword' => $SignupPwd,
    'VarSurname' => $SignupSurn
    );

    var_dump($templateData['VarFirstName']); exit;

    $email->populateTemplate($templateData);

    Where are the $SignupFirst and friends coming from, can you show more code?

    cheers,
    mat

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Populate Data? How Works? Link to this post

    Thank you for your reply.

    The code is:

    function Invia_Email_Registrazione($data) {

    $from="info@abc.zxx";
    $to=$data['Email'];
    $subject="Confirmed";
    $body="";
    $email = new Email($from, $to, $subject, $body);
    $email->setTemplate('SignUp');
    $SignupFirst=$data['FirstName'];
    $SignupSurn=$data['Surname'];
    $SignupEmailAddress=$data['Email'];
    $SignupPwd=$data['Password'];
    $welcomeMsg = ' Ti sei registrato il '.date('Y-m-d'.'!');

    $data coming from function SignupAction($data, $form) because I call $this->Invia_Email_Registrazione($data) into SignupAction.

    Bye

  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: Populate Data? How Works? Link to this post

    And what about the debug code output?

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Populate Data? How Works? Link to this post

    Debug?
    Have I to add ?debug=1 after url? ok.

    Tested: I've not any errors and I'don't see, with debug=1, where registration form call send email function and populate data...

    And How Can I use some debug output into code?

  • MateuszU
    Avatar
    Community Member
    89 Posts

    Re: Populate Data? How Works? Link to this post

    Just put the line

    var_dump($variable_to_display); exit;

    into the code somewhere and use the page as normal. var_dump will print out the content of the variable (object or whatever) and exit will kill the program just afterwards, so you will be able to see the output. See the code block in my first post.

    mat

    1271 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.