Hi:

In page.tpl.php, I am trying to get my $messages to print a certain way, but don't really know php too well / at all.

I want to print messages in one way for visitors and another for admin users.

I've got the statement below in place and this works for visitors, but lacks the 'else' part to say waht to print for admin.

<?php if ($messages && arg(0) != 'admin' && $user->name != admin) { print '<div class="message-wrapper"><p class="message-header">Sorry, there was a problem:</p>' . $messages . '<p class="message-footer">Please contact us by email at info@xyz.com if you need further assistance. Thanks!</p></div>'; } ?>

i tried this else statement, but it didn't work

<?php if ($messages && arg(0) != 'admin' && $user->name != admin) { print '<div class="message-wrapper"><p class="message-header">Sorry, there was a problem:</p>' . $messages . '<p class="message-footer">Please contact us by email at info@xyz.com if you need further assistance. Thanks!</p></div>'; }  else { print $messages }?>

Can someone help me tweak this to get it to print for both cases, please?

Thank you!

Comments

zbricoleur’s picture

...you're just missing the semicolon after the last $messages

mshepherd’s picture

Something like:?

<?php if ($messages && arg(0) != 'admin' && $user->name != admin) { ?>
  <div class="message-wrapper">
    <p class="message-header">Sorry, there was a problem:</p>
    <p class="message-text"><?php print $messages; ?></p>
    <p class="message-footer">Please contact us by email at <a href="mailto:info@xyz.com" rel="nofollow"> info@xyz.com</a> if you need further assistance. Thanks!</p>
  </div>
<?php } elseif ( $messages ) {
  print $messages;
}?>
john.kenney’s picture

that works!

and it is much prettier, too.

thank you both very much!!