Vesthelm Engine

2.1.1 User Guide

Router Class

Calling the Router Class

$Router = $this->Router;

Getting an Enhancement Name

//Example URL: http://www.example.com/index.php/bulletin-board/bulletins/add/
//Multi language example URL: http://www.example.com/index.php/ru-RU/bulletin-board/bulletins/add/
//Default enhancement example URL: http://www.example.com/index.php/bulletins/add/

$enhancement = $this->Router->getEnhancement();

echo $enhancement; //Outputs: bulletin_board

Getting a Controller Name

//Example URL: http://www.example.com/index.php/bulletin-board/bulletins/add/
//Multi language example URL: http://www.example.com/index.php/ru-RU/bulletin-board/bulletins/add/
//Default enhancement example URL: http://www.example.com/index.php/bulletins/add/

$controller = $this->Router->getController();

echo $controller; //Outputs: bulletins

Getting an Action Name

//Example URL: http://www.example.com/index.php/bulletin-board/bulletins/add/
//Multi language example URL: http://www.example.com/index.php/ru-RU/bulletin-board/bulletins/add/
//Default enhancement example URL: http://www.example.com/index.php/bulletins/add/
//$_GET example URL: http://www.example.com/index.php/bulletin-board/bulletins/?action=add
//$_POST['action'] = 'add'; URL: http://www.example.com/index.php/bulletin-board/bulletins/

$action = $this->Router->getAction();

echo $action; //Outputs: add

Getting Frontend Language Code

//Multi language example URL: http://www.example.com/index.php/ru-RU/bulletin-board/bulletins/add/
//$_GET example URL: http://www.example.com/index.php/bulletin-board/bulletins/add/?vlc=ru-RU
//$_COOKIE['v_lc'] = 'ru-RU'; URL: http://www.example.com/index.php/bulletin-board/bulletins/add/

$lang_code = $this->Router->getLangCode();

echo $lang_code; //Outputs: ru-RU

Getting ACP Language Code

//$_GET example URL: http://www.example.com/acp/index.php/bulletin-board/bulletins/add/?vlc=ru-RU
//$_COOKIE['v_lc'] = 'ru-RU'; URL: http://www.example.com/acp/index.php/bulletin-board/bulletins/add/

$lang_code = $this->Router->getAcpLangCode();

echo $lang_code; //Outputs: ru-RU