In my preprocess_page() function, I'm setting variables based on the user that is logged in.
I created a custom page that is used as a Welcome page with the information about the user that I set in the variables in the preprocess_page() function.
The problem I have is that the page is not allowing me to put the print statements to echo out the variable, i.e.
<h1 style="font-size:18px; padding-bottom:3px;"><?php print $FirstName. " ".$LastName; ?></h1>
It doesn't echo out the variable values.
Also, I need later to do something based on the value of a variable. I have tried using an if statement like this:
<?php
if($designations == 'ABCDE') {
?>
<td align="center" style="width: 40px;"><img src="images/abcde.png" alt=""></td>
</php
} else {
?>
<td align="center" style="width: 40px;"> </td>
<?php
}
but all it does is print out part of the PHP:
if($designations == 'ABCDE') {
?>
} else {
?>
What am I doing wrong here???
Updated (Added preprocess_page function code):
function mix_and_match_preprocess_page(&$vars) {
$vars['page_color'] = theme_get_setting('mix_and_match_page_bg');
if(user_is_logged_in()) {
// Get the user's info and assign the values to variables.
$vars['ParticipantID'] = 1007945;
$vars['Username'] = 'JOESMITH';
$vars['Password'] = 'passwd';
$vars['FirstName'] = 'Joe';
$vars['MiddleName'] = '';
$vars['LastName'] = 'Smith';
$vars['Suffix'] = '';
$vars['PreferedEmailAddress'] = 'joe_smith@mysite.com';
} // if($logged_in)
}
Showing new code and results: This code:
<h1 style="font-size:18px; padding-bottom:3px;"><?php print $FirstName. " ".$LastName; ?></h1>
produces (When view source):
<h1 style="font-size:18px; padding-bottom:3px;"><?php print $FirstName. " ".$LastName; ??></h1>
this code:
drupal_set_message('I got here');
<?php if($designations == 'ABCDE': ?>
<td align="center" style="width: 40px;"><img src="images/cic-35x29.png" alt=""></td>
drupal_set_message('I got here');
<?php else: ?>
<td align="center" style="width: 40px;"> </td>
<?php endif; ?>
produces (When view source):
drupal_set_message('I got here');<br />
<?php if($designations == 'UACIC'): ??>
<td align="center" style="width: 40px;"><img src="images/cic-35x29.png" alt="" /></td>
<p>drupal_set_message('I got here');<br /><?php else: ??></p>
<td align="center" style="width: 40px;"> </td>
<p><?php endif; ??>
drupal_set_message('I got here');
style debugging in there to make sure all your logic is actually happening. Also, from a pure style and ease of reading standpoint, I'd use the<?php if(foo): ?> ////// <?php endif; ?>
style in your templates instead of the{}
style you have now, too.