once again a simple question to the forum...
is there a build in method in yii to return the current page?
i don't mean the page number, i mean the actual page.
so for example if a page is in site/index.php
then i want yii to tell me that the page is "site/index.php" or "site/index"
Page 1 of 1
get current webpage in yii? how? the page name, not its page count
#2
Posted 08 September 2009 - 07:09 AM
Yii::app()->getController() returns the current controller. With CController::getAction() you can access the current action.
#3
Posted 08 September 2009 - 07:15 AM
For the url, access Yii::app()->request->requestUri. For the other case, see the post above.
#4
Posted 08 September 2009 - 07:47 AM
Dave gave exactly what i wanted, thanks!
i am currently getting it like this
not sure if this is how its meant to be taken out...
as for the Yii::app()->request->requestUri.
isn't $_SERVER['REQUEST_URI'] the same thing?
i am currently getting it like this
$curpage = Yii::app()->getController()->getAction()->controller->id; $curpage .= '/'.Yii::app()->getController()->getAction()->controller->action->id; return $curpage;
not sure if this is how its meant to be taken out...
as for the Yii::app()->request->requestUri.
isn't $_SERVER['REQUEST_URI'] the same thing?
#5
Posted 08 September 2009 - 10:27 AM
Outside of the view file I use
url then would be something like
inside view simplify with
See http://www.yiiframew...questUri-detail for details about requestUri.
Yii::app()->controller->getId() Yii::app()->controller->getAction()->getId()
url then would be something like
CHtml::normalizeUrl(array(Yii::app()->controller->getId().'/'.Yii::app()->controller->getAction()->getId()))
inside view simplify with
$this->getId() $this->getAction()->getId()
See http://www.yiiframew...questUri-detail for details about requestUri.
#6
Posted 08 September 2009 - 01:11 PM
thank you phpdevmd
it was very informative (and makes life easier)
now i can safely put it in, knowing that im not messing up the whole purpose of the framework.
it was very informative (and makes life easier)
now i can safely put it in, knowing that im not messing up the whole purpose of the framework.
Share this topic:
Page 1 of 1

Help
This topic is locked













