简体   繁体   中英

ZEND_Auth, deactivate navigation area

I´ve built a Login Page using Zend_Auth. Now my question ist how can I deactivate areas which are loaded with my layout.phtml?

Here the part of my code of my layout.phtml which I don´t want to see in my login and logout forms:

<div id="navigation">
    <ul>
            <li><a href="<?php echo $this->url(array('controller'=>'arbeitskalender', 'action'=>'index'), null, false);?>">Arbeitskalender</a></li>
            <li><a href="<?php echo $this->url(array('controller'=>'pdf', 'action'=>'index'));?>">Arbeitskalender download</a></li>
            <!--<li><a href="<?php echo $this->url(array('controller'=>'bibliothek', 'action'=>'index'));?>">Bibliothek</a></li> -->
            <!-- <li><a href="<?php echo $this->url(array('controller'=>'schwestern', 'action'=>'index'));?>">Schwestern</a></li> -->
    </ul>
</div>

How can I work with different layouts? In which place and how can I load them?

You can have multiple layouts in an application. If you create another without the navigation HTML and configure it in your module.config.php , you can simply select which layout to use from within the controller.

'template_map' => array(
    'layout/layout'       => __DIR__ . '/../view/layout/layout.phtml',
    'layout/layout_login' => __DIR__ . '/../view/layout/layout_login.phtml'
)

Then in your controller:

$this->layout('layout/layout_login');

EDIT:

Alternatively if you'd like to dynamically change your layout you can use the Identity View Helper to check whether a user is logged in or not. eg

<!-- if logged in, show logout link -->
<?php if (null !== $this->identity()) : ?>
    <a href="/logout">Logout</a>
<?php endif; ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM