Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.

A PHP Snippet

edited October 2006 in Vanilla 1.0 Help
I need a PHP snippet to create a welcome message on a PageManager page.
Can anyone fill in the green bits and correct syntax for me...

if someone is logged in
   echo 'Hello whoever'
else
   echo 'Please log in';

Comments

  • edited October 2006
    Don't know about PageManager, but this is a way to do it in an extension: (I did it similar to this for both GuestSignin and Guestsense)
    if ( ($Context->UserID > 0) && in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "search.php") ) { echo "Hello " . $Context->User->Name; // I think this is right.... } else { echo "Please log in"; }

    ::mumbles something about mac users not knowing how to program:: (Kidding!)
  • What do you mean not knowing how to program? He's using the new mac programming language! English! I'd buy a mac today if i could program like that on it :(
  • PHP code in a page created by the page manager acts like code in a function, so you're going to have to use the $GLOBALS array to access global variables (either simply access array elements or make a reference to an index):
    if($GLOBALS['Context']->Session->RoleID) echo 'Hello '.$GLOBALS['Context']->Session->User->Name;
    else echo 'Please log in';
  •  Quote: WallPhone  ::mumbles something about mac users not knowing how to program:: (Kidding!)
    Thanks WallPhone and SirNot, I'll give that a go.

    And no I don't know PHP, I hack at it and make it do what I want usually, all I need is an example to get me going.

    Also for the record, I'm not a "great" designer either, I'm a teacher by trade, this web stuff is a hobby which I have become good at, so they tell me.
This discussion has been closed.