I wrote an assistant to make my main navigator. Part of this helper checks if a user is registered, checking if the user has been assigned to submit
if($this->view->user)
{
}
However, when I call this helper in my script layout, it cannot access this user -> view->; it is NULL (although var_dump ($ this-> view returns a view object, jsut does not have all the properties assigned to it). It can only access user data if I assign its layout in the script view, i.e.
$this->layout()->user = $this->user;
And then in the assistant do
if($this->view->layout()->user)
{
}
Which is a pain as it means in every view of the script I need to add a line to pass data to the layout.
, script, ?
*
:
<?php
class Zend_View_Helper_MainNav extends Zend_View_Helper_Abstract {
public function mainNav()
{
if ($this->view->layout()->navType == 'none'){
$html = '<div id="nav"><a href="/" id="logo">Sum puzzles</a></div>';
} else if($this->view->layout()->navType == 'small'){
$html = '<div id="nav" class="small"><a href="/" id="logo">Sum puzzles</a><ul>' .
'<li><a href="/puzzle/view" class="button">play a puzzle</a></li>' .
'<li><a href="/sequence/play" class="button">puzzle sequences</a></li>' .
'<li><a href="/puzzle/create" class="button">create a puzzle</a></li>';
if(!$this->view->user)
{
$html .= '<li><a href="/teachers" class="button">teachers area</a></li>';
}
$html .='</ul></div>';
} else if($this->view->layout()->navType == 'large'){
$html = '<div id="nav" class="large"><a href="/" id="logo">Sum puzzles</a><ul>' .
'<li><a href="/sequence/play" class="playSequence">Play a sequence of puzzles</a></li>' .
'<li><a href="/puzzle/create" class="createPuzzle">Create your own puzzles</a></li>';
if(!$this->view->user)
{
$html .= '<li><a href="/teachers" class="teachersArea">teachers area</a></li>';
}
$html .= '</ul></div>';
}
return $html;
}
}