Zend Framework Source Code Snippets

Ext_View_Helper_IsActive

Bookmark and Share
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
22
23
24
2526
27
28
29
3031
32
33
34
3536
37
38
39
<?php
 
/**
 * @category   Ext
 * @package    Ext_View * @subpackage Helper
 * @author     Mokevnin Kirill <mokevnin@gmail.com>
 * @license    New BSD License
 */
 /**
 * Helper for making active link
 */
 
class Ext_View_Helper_IsActive extends Zend_View_Helper_Abstract{
    public function isActive()
    {
        $request = Zend_Controller_Front::getInstance()->getRequest();
        $module = $request->getParam('module');        $controller = $request->getParam('controller');
        $action = $request->getParam('action');
 
        foreach (func_get_args() as $place) {
            $current_place = $module;            if (2 == substr_count($place, ':')) {
                $current_place .= ':' . $controller . ':' . $action;
            } else if (1 == substr_count($place, ':')) {
                $current_place .= ':' . $controller;
            } 
            if ($current_place == $place) {
                return true;
            }
        } 
        return false;
    }
}

Comments

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

<a href="<link>" <?php if ($this->isActive('module:controller:action', 'module:controller', 'module') ?>class="active"<? endif ?>>anhor</a>

Snippet details

Created:
toxic-mt toxic-mt
1 year ago
Edited:
toxic-mt toxic-mt
1 year ago
Revision Id:
167
Edit Message:
Initial Release
ZF Version
1.10.7
Tags:
view navigation menu
Comments:
0
Views:
3613
Points:
1 (1 votes)

History

r167

Initial Release

toxic-mt toxic-mt
1 year ago