2010年3月23日星期二

Re: [fw-mvc] Conditional links in Zend_Navigation

Hello everyone,

Thanks for the quick reactions. I have done some research on the web and i found some interesting video tutorials on the web (Youtube: http://bit.ly/aqnuwb). There there are a couple of video tutorials about Zend_Navigation and combining it with zend Acl.

The only thing is that I use the whole acl functionallity in a different way. Namely ad described in the book of Keith Pope (Zend Framework 1.8 Web application development). I am using a model based ACL.

Here I use the ACL as an action helper: 

        Zend_Controller_Action_HelperBroker::addHelper(new SF_Controller_Helper_Acl());

The problem I have is that I don't know how to access the ACL from the bootstrap in order to add the acl to zend _navigation in this way:

$navigation = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml','nav');
$navContainer = new Zend_Navigation($navigation);
$this->_view->navigation($navContainer)-setAcl($this->_acl)->setRole($this->_auth->getStorage()->read()->role); 


Any Idea's?


On Sun, Mar 21, 2010 at 11:19 PM, Jelle-Jan van Veelen - Zicht <jellejan@zicht.nl> wrote:

The easiest way to do this, is to use Zend_Navigation together with Zend_Acl. It's a pretty easy setup.

First, you build your ACL where you define something like a user (logged in) and a guest (not logged in). You can allow or deny users or guest certain resources, and a Zend_Navigation_Page could be one of those resources. So, when your navigation is rendered, and a certain page is defined as a resource in your ACL, Zend_Navigation will check the ACL if the current user has the rights to view that page.

 

You will have to keep in mind that this ACL checking is only done on the navigation itself, and not on the specific controller/action when it is requested. So, the link to the logout page is hidden when someone is not logged in, but that does not mean a guest cannot visit the logout page.

 

If you do a web search on Zend_Navigation Zend_Acl you will find a lot of examples that will get you started.

 

Jelle-Jan

 

From: Jigal sanders [mailto:jigalroecha@gmail.com]
Sent: zondag 21 maart 2010 21:16
To: fw-general; fw-mvc
Subject: [fw-mvc] Conditional links in Zend_Navigation

 

Hello,

 

I use Zend_Navigation and an xml file to build up my navigation.

Is it possible to show only a link on a certain condition? For example when a user is logged in i want to show the logout link but when no one is logged in i don't want to show the logout link.

 

Any idea's?

 

Thanks.

 

J. Sanders




--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

没有评论: