Yii Framework Forum: Error when parsing URL, please... - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error when parsing URL, please... Rate Topic: -----

#1 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 15 March 2010 - 04:51 AM

I get a problem when I using
parseUrl
function.

I write this code;
echo '<pre>';
var_dump(Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest()->requestUri));


but I get this error:
Fatal error:  Call to a member function getPathInfo() on a non-object in /mnt/win_d/www/website/latihan/yii/framework/web/CUrlManager.php on line 297


any one can help me please!!

thank you for all
Thanks and Kind Regards
------
DanDinDun
0

#2 User is offline   jsoo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 01-March 10
  • Location:Durham, NC, USA

Posted 15 March 2010 - 06:56 AM

View PostDan Din Dun, on 15 March 2010 - 04:51 AM, said:

I get this error:
Fatal error:  Call to a member function getPathInfo() on a non-object in /mnt/win_d/www/website/latihan/yii/framework/web/CUrlManager.php on line 297



CHttpRequest::getRequest()->requestUri is a string, whereas CUrlManager::pasreUrl() expects a CHttpRequest object.

This is valid:

Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest())


Edit: although, I suppose, not generally needed, as this should give the same result as

Yii::app()->getRequest()->requestUri

0

#3 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 15 March 2010 - 07:59 AM

View Postjsoo, on 15 March 2010 - 06:56 AM, said:

CHttpRequest::getRequest()->requestUri is a string, whereas CUrlManager::pasreUrl() expects a CHttpRequest object.

This is valid:

Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest())


Edit: although, I suppose, not generally needed, as this should give the same result as

Yii::app()->getRequest()->requestUri



Oh.. yes thank, but sir. how if I want to get a url parsed. I means like.

eg: http://myapp.com/ind...p/products/id/6

that above link is generated using
Yii::app()->createUrl(array('/products','id' => 6))

how to parse that link (http://myapp.com/ind...p/products/id/6) into
array('/products','id' => 6))


any idea sir?
Thanks and Kind Regards
------
DanDinDun
0

#4 User is offline   jsoo 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 01-March 10
  • Location:Durham, NC, USA

Posted 15 March 2010 - 08:55 AM

I don't know if this is available in core Yii (I'm not that experienced, so don't take my word for it). The second part ('id'=>6) you can get from the $_GET array. The first bit you could get from Yii::app()->controller->id. If there is an action as well (e.g., '/products/update') I guess you'd have to make your own parse function.
0

#5 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 15 March 2010 - 06:37 PM

View Postjsoo, on 15 March 2010 - 08:55 AM, said:

I don't know if this is available in core Yii (I'm not that experienced, so don't take my word for it). The second part ('id'=>6) you can get from the $_GET array. The first bit you could get from Yii::app()->controller->id. If there is an action as well (e.g., '/products/update') I guess you'd have to make your own parse function.

Ow great sir, your reply is very useful for me, yes If in yii don't provide this function, maybe I will make own...
thanks sir :-)
Thanks and Kind Regards
------
DanDinDun
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users