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

Populate Data? How Works?


Reply

6 Posts   1306 Views

Avatar
biapar

29 January 2010 at 2:06am Forum Moderator, 435 Posts

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?

Avatar
MateuszU

1 February 2010 at 9:59am Community Member, 89 Posts

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

Avatar
biapar

4 February 2010 at 11:24pm Forum Moderator, 435 Posts

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

Avatar
MateuszU

5 February 2010 at 1:33pm Community Member, 89 Posts

And what about the debug code output?

Avatar
biapar

7 February 2010 at 11:55pm (Last edited: 8 February 2010 12:12am), Forum Moderator, 435 Posts

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?

Avatar
MateuszU

8 February 2010 at 9:04am (Last edited: 8 February 2010 9:04am), Community Member, 89 Posts

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