2017 © Pedro Peláez
 

library zf2-current-route

View Helper for reading current route info: Controller, Action, Module name

image

tasmaniski/zf2-current-route

View Helper for reading current route info: Controller, Action, Module name

  • Wednesday, October 12, 2016
  • by tasmaniski
  • Repository
  • 2 Watchers
  • 19 Stars
  • 867 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

Licence PHP version, (*1)

IMPORTANT NOTE: 
If you find this package useful, 
please click on a star button and let me know, 
so I will gladly continue with the updates.

Laminas MVC - Current Route Helper

View Helper for reading Controller, Module, Action and Route name in any view(.phtml) file including layout.phtml, (*2)

Install

Add in you composer.json file:, (*3)

{
    "require": {
        "tasmaniski/laminas-current-route": "^3.0"
    }
}

After running: composer update, (*4)

You need to register new module. Add in file config/application.config.php:, (*5)

'modules' => array(
    '...',
    'CurrentRoute'
),

Use

Use this view helper in your view files(.html) including layout.phtml, (*6)

// get current route info
$this->currentRoute()->getController();               // return current controller name
$this->currentRoute()->getAction();                   // return current action name
$this->currentRoute()->getModule();                   // return current module name
$this->currentRoute()->getRoute();                    // return current route name

// or simply check with current info
$this->currentRoute()->matchController('index');      // match "index" with current controller name
$this->currentRoute()->matchAction('index');          // match "index" with current action name
$this->currentRoute()->matchModule('application');    // match "application" with current module name
$this->currentRoute()->matchRoute('home');            // match "home" with current route name

Real world example

<?php $css_class = $this->currentRoute()->matchModule('admin') ? 'selected' : ''; ?>
<a href="/admin" class="<?php echo $css_class;?>">
    Admin link
</a>

The Versions

12/10 2016

dev-master

9999999-dev https://github.com/tasmaniski

View Helper for reading current route info: Controller, Action, Module name

  Sources   Download

The Requires

 

by Aleksandar Varnicic

helper route zend framework view

12/10 2016

2.0.0

2.0.0.0 https://github.com/tasmaniski

View Helper for reading current route info: Controller, Action, Module name

  Sources   Download

The Requires

 

by Aleksandar Varnicic

helper route zend framework view

16/10 2015

1.0.3

1.0.3.0 https://github.com/tasmaniski

View Helper for reading current route info: Controller, Action, Module name

  Sources   Download

The Requires

 

by Aleksandar Varnicic

helper zf2 route view

11/10 2015

1.0.2

1.0.2.0 https://github.com/tasmaniski

View Helper for reading current route info: Controller, Action, Module name

  Sources   Download

The Requires

 

by Aleksandar Varnicic

helper zf2 route view

08/10 2015

1.0.1

1.0.1.0 https://github.com/tasmaniski

View Helper for reading current route info: Controller, Action, Module name

  Sources   Download

The Requires

 

by Aleksandar Varnicic

helper zf2 route view

06/10 2015

1.0.0

1.0.0.0 https://github.com/tasmaniski

View Helper for reading current route info: Controller, Action, Module name

  Sources   Download

The Requires

  • php >=5.3

 

by Aleksandar Varnicic

helper zf2 route view