Yii Framework Forum: Having issues extending CUrlManager - Yii Framework Forum

Jump to content

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

Having issues extending CUrlManager Rate Topic: -----

#1 User is offline   kaamoss 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 10-November 10

Posted 30 November 2010 - 11:33 AM

Hey Everyone,
So I'm trying to create my own class that extends CUrlManager so I can take a url like /something/else/23342 and based on that / the host name, parse that url into something like index.php?r=controler/action . This is working fine actually, the only problem is that if I append &somevar=something to what parseUrl($request) returns, I get a 404 error "The system is unable to find the requested action "view&id=1"."

So it seems like adding any extra parameters to pass to the action cuts off the controller portion of what the function returns. Can anyone provide some insight into what I'm doing wrong? I'm very new to Yii so hopefully this isn't a stupid question.

class PUrlManager extends CUrlManager {
    public function parseUrl($request) {
		$rawPathInfo=$request->getPathInfo();
        print('<pre>');
        var_dump($_SERVER["HTTP_HOST"]);
        print('</pre>');

        print('<pre>');
        var_dump($rawPathInfo);
        print('</pre>');

        if(isset($_GET[$this->routeVar])) {
            if($_GET[$this->routeVar] == 'site/login') {
                return 'site/login';
            }
        }

        else
            return "project/view&id=1";
    }
}

0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 01 December 2010 - 03:32 AM

Are you sure you could not get the same result with the url manager that comes with Yii? It's very powerful and takes you a long way before you find a situation where you really have to extend CUrlManager. See here:

http://www.yiiframew...1/en/topics.url
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