Alex Tech Adventures The webs best tutorials!

Welcome, Guest
Please Login or Register.    Lost Password?

Site navigation based on logon permissions
(0 viewing) 
Go to bottomPage: 1234
TOPIC: Site navigation based on logon permissions
#136
Re:Site navigation based on logon permissions 2 Years, 3 Months ago Karma: 0
Successfully completed this task
Pasted into navigation.xml <module></module> tags and it works fine
01Kuzma
Fresh Boarder
Posts: 14
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#225
Re:Site navigation based on logon permissions 2 Years, 2 Months ago Karma: 0
Thanks for the nice tutorial. I'd have one question regarding rendering a navigation in a view. The following code works fine on a layout, but the navigation will not get rendered when placed in the view. Any thoughts?

<?php

$navigation = $this->navigation()->findOneByLabel('Activity');
$options = array(
'indent' => 16,
'ulClass' => 'content-navigation',
'minDepth' => 0,
'maxDepth' => 0
);
echo $this->navigation()
->menu()
->renderMenu($navigation, $options);
?>

Cheers,
jarnom
jarnom
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#227
Re:Site navigation based on logon permissions 2 Years, 2 Months ago Karma: 16
strange, becuase i copied and pasted that code right into my view phtml template and shows the same thing as if it would in layout phtml
alexanderrv
Administrator
Posts: 279
graph
User Offline Click here to see the profile of this user
Gender: Male tmthv2 alexchatonly@hotmail.com Location: Freeport, Bahamas Birthdate: 1989-04-14
The administrator has disabled public write access.
 
#230
Re:Site navigation based on logon permissions 2 Years, 2 Months ago Karma: 0
Thanks for your answer. I added Zend_Registry::set('Zend_Navigation', $navContainer); to the end of the Bootstrap file and the view.phtm files render the navigation again. Don't know if this is an elegant solution. Something wrong with my Boothstrapping perhaps?


<?php

/**
* Application bootstrap
*
* @uses Zend_Application_Bootstrap_Bootstrap
* @package Default
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Bootstrap autoloader for application resources
*
* @return Zend_Application_Module_Autoloader
*/

private $_acl = null;

protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(
array(
'namespace' => '',
'basePath' => APPLICATION_PATH.'/modules/default'
));

// Note: this has been moved to application.ini
//$autoloader = Zend_Loader_Autoloader::getInstance();
//$autoloader ->registerNamespace(array('jpgraph_'));

if(Zend_Auth::getInstance()->hasIdentity()) {

Zend_Registry::set('role', Zend_Auth::getInstance()->getStorage()->read()->role);

} else {
Zend_Registry::set('role', 'guests');
}

$this->_acl = new Model_AppAcl;
$this->_auth = Zend_Auth::getInstance();

$fc = Zend_Controller_Front::getInstance();
$fc->registerPlugin(new Plugin_AccessControl($this->_acl));

return $moduleLoader;

}


/**
* bootstraping layout, view and doctype and initiating navigation
* @return Zend_Navigation
*/

protected function _initMainNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();

$view->doctype('XHTML1_STRICT');
$view->headTitle('Title');
$view->headLink()->appendStylesheet('/css/main.css');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=uft-8');
$view->headMeta()->appendName('keywords', 'keywords');

$view->setHelperPath(APPLICATION_PATH.'/layouts/helpers',''); // Common helpers

$navContainerConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');

$navContainer = new Zend_Navigation($navContainerConfig);

$view->navigation($navContainer)->setAcl($this->_acl)->setRole(Zend_Registry::get('role'));
Zend_Registry::set('Zend_Navigation', $navContainer);
}

}

If I do var_dump($this->navigation)); I get:

object(Zend_View_Helper_Navigation)#292 (17) { ["_defaultProxy:protected"]=> string(4) "menu" ["_helpers:protected"]=> array(0) { } ["_injectContainer:protected"]=> bool(true) ["_injectAcl:protected"]=> bool(true) ["_injectTranslator:protected"]=> bool(true) ["_container:protected"]=> object(Zend_Navigation)#293 (3) { ["_pages:protected"]=> array(0) { } ["_index:protected"]=> array(0) { } ["_dirtyIndex:protected"]=> bool(false) } ["_minDepth:protected"]=> NULL ["_maxDepth:protected"]=> NULL ["_indent:protected"]=> string(0) "" ["_translator:protected"]=> NULL ["_acl:protected"]=> NULL ["_renderInvisible:protected"]=> bool(false) ["_role:protected"]=> NULL ["_useTranslator:protected"]=> bool(true) ["_useAcl:protected"]=> bool(true) ["_closingBracket:protected"]=> NULL ["view"]=> object(Zend_View)#266 (18) { ["_useViewStream:private"]=> bool(false) ["_useStreamWrapper:private"]=> bool(false) ["_path:private"]=> array(3) { ["script"]=> array(1) { [0]=> .... // * content cut.
jarnom
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2009/12/03 16:50 By alexanderrv.Reason: code tags didn\'t work
The administrator has disabled public write access.
 
#231
Re:Site navigation based on logon permissions 2 Years, 2 Months ago Karma: 16
There should be no need to put Z_Navigation in registry. The fact that you have to do it and the fact that view does not work even though you did assign navigation object to navigation view helper, means that you are probably accidentally overwriting navigation stuff from its view helper after it is being displayed in the layout.
alexanderrv
Administrator
Posts: 279
graph
User Offline Click here to see the profile of this user
Gender: Male tmthv2 alexchatonly@hotmail.com Location: Freeport, Bahamas Birthdate: 1989-04-14
The administrator has disabled public write access.
 
#335
Site navigation based on logon permissions 2 Years ago Karma: 0
Hi Alex

I am getting an error in the page
Fatal error: Uncaught exception 'Exception' with message 'Invalid cache options; must be array or Zend_Config object'
could you please help me for resolving this issue

Thanks
siva
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1234
Moderators: alexanderrv
You are here: Home Forum

Statistics

Members : 1401
Content : 42
Web Links : 1
Content View Hits : 191197

Poll

Interested in TinyBrowser and TinyMce plugin for ZF?
 

Who's Online

We have 48 guests online