Zend URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Scrumpy.Gums
Forum Commoner
Posts: 71
Joined: Thu Aug 30, 2007 2:57 pm
Location: Bristol, UK

Zend URL

Post by Scrumpy.Gums »

Hi,
I'm giving Zend another try and have come across a slight hitch :( I want the URL to be http://localhost/event/title/a-title, using EventController.php. The problem is that it tries to interpret title as an action, but I want it to use it as a $_GET parameter.

It works fine if I use an IndexController.php with an eventAction i.e. the URL is:
http://localhost/index/event/title/a-title. But I'd like to get rid of the index part. :?

The other situation it works is using the URL http://localhost/event?title=a-title. I've tried using a RewriteRule in the main .htaccess but that doesn't seem to work. The Rule I used was:
RewriteRule ^event/title/(.*)$ /event?title=$1

Any suggestions as to how I could accomplish this? :|
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Zend URL

Post by Christopher »

In "/event/title/a-title" and "/index/event/title/a-title", what is the module, controller, action and params?
(#10850)
Scrumpy.Gums
Forum Commoner
Posts: 71
Joined: Thu Aug 30, 2007 2:57 pm
Location: Bristol, UK

Re: Zend URL

Post by Scrumpy.Gums »

In "event/title/a-title":
Controller: event
Action: index
Param: title

In "index/event/title/a-title":
Controller: index
Action: event
Param: title

Not sure what the module is :oops:

With the first one, it's doing the logical thing i.e. Controller/Action/Param, but I want it to do something less logical :dubious: ... I want it to use index as the action, not title. Is there any way to do that without having to use "event/index/title/a-title"? Hope that makes sense.. :|

many thanks.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Zend URL

Post by Christopher »

Scrumpy.Gums wrote:I want it to use index as the action, not title. Is there any way to do that without having to use "event/index/title/a-title"?
Yes, you need to define routes for those that are different. Check to documentation for the Front Controller and Router.
(#10850)
Scrumpy.Gums
Forum Commoner
Posts: 71
Joined: Thu Aug 30, 2007 2:57 pm
Location: Bristol, UK

Re: Zend URL

Post by Scrumpy.Gums »

great, I'll look into that. :wink:
Post Reply