has like getRoute() function?

sometime, i want to get the current route without additional parameters~

like in action:

echo $this->route; <-- site/misc

echo $this->route; <-- mymodule/product/list ( in module )

[color="#9932CC"]BTW:

sometime, will want through route to get more information for moduleId, controllerId, and actionId

this function will look like:

$routeResource = Yii::app()->urlManager->parseRoute(‘user/update’);

$routeResource will have:

moduleId => null,

controllerId => user,

actionId => update,[/color]

qiang?

I needed something like this so i created a BaseController then extended from it a FrontendController then from that i extended all my front end controllers. in my BaseController i have code like this


<?php


class BaseController extends CController

{

	public function init()

	{

		parent::init();

	}

	

	public function beforeAction($action)

	{

		return parent::beforeAction($action);

	}

	

	/**

	 * Declares class-based actions.

	 */

	public function actions()

	{

		return array(

			// captcha action renders the CAPTCHA image

			// this is used by the contact page

			'captcha'=>array(

				'class'=>'CCaptchaAction',

				'transparent'=>true,

			),

		);

	}

	

	public function routeIsActive($pattern,$controllerID,$actionID)

	{

		if(!is_array($pattern) || !isset($pattern[0]))

			return false;


		$pattern[0]=trim($pattern[0],'/');

		if(strpos($pattern[0],'/')!==false)

			$matched=$pattern[0]===$controllerID.'/'.$actionID;

		else

			$matched=$pattern[0]===$controllerID;


		if($matched && count($pattern)>1)

		{

			foreach(array_splice($pattern,1) as $name=>$value)

			{

				if(!isset($_GET[$name]) || $_GET[$name]!=$value)

					return false;

			}

			return true;

		}

		else

			return $matched;

	}

}

following that, to achieve what u want you can add a method eg: getActiveRoute




	public function getActiveRoute()

	{

		$controller = $this->uniqueID;

		$action = $this->action->id;

		return $route = $controller.'/'.$action;

	}



Then in all your controllers/views/widgets you can get the active route by calling $controllerInstance->getActiveRoute();

I figure it can be modified to deal with nested modules.

where $controllerInstance is the instance of your controller.