Jump to content

Recommended Posts

I'm adapting a "page class" that provides the interface and menu across a site.  For this particular project, there will be multiple user types which will have different menu options.  I'm trying to integrate these variations in the "page class" include file.  Problem is, i get php validation errors because it's expecting only functions, not "if/else" statements.

 

Ultimately what i need is for the "row2buttons" array to be set by a "usertype" condition, but i can't figure out how.

  function Display()
  {
    echo "<html>\n<head>\n";
    $this -> DisplayTitle();
    echo "</head>\n<body>\n";
    $this -> DisplayHeader();
    $this -> DisplayMenu($this->buttons);
$this -> DisplayMenu($this->row2buttons);
    echo $this->content;
    $this -> DisplayFooter();
    echo "</body>\n</html>\n";
  }

 

If there's any details I've failed to mention please let me know.  Thank you in advance.

 

I thought of that, too, but I'm having trouble with that.  I don't wish to specify it on each page the user visits so that's out.  And if i put an if/else clause on the class include file, there's 2 places i can try to put it - inside the class, or outside the class.  Inside, it complains that the if/else isn't a function and so doesn't belong inside the class.

 

Outside, the "DisplayMenu($this->row2buttons);" doesn't seem to be able to pull in an array at all. It complains that it's not an array.

Alright well thanks anyway everyone but I'm about to answer my own question.  I was putting it in the wrong place inside the function.  Fixed as follows:

  function Display()
  {
            if ($usertype==1)
    {
    		$row2buttons = array(
		'A' => 'a.php',
                        'B' => 'b.php');
    }
elseif ($usertype==2)
	{
		$row2buttons = array(
		'C' => 'c.php',
		'd' => 'd.php');
	}
    echo "<html>\n<head>\n";
    $this -> DisplayTitle();
    echo "</head>\n<body>\n";
    $this -> DisplayHeader();
    $this -> DisplayMenu($this->buttons);
        $this -> DisplayMenu($this->row2buttons);
    echo $this->content;
    $this -> DisplayFooter();
    echo "</body>\n</html>\n";
  }

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.