[Solar-talk] Re: [Solar-svn] Revision 3037 (a.k.a page black-list)
Leo Chiao
leo.chiao at gmail.com
Mon Mar 24 14:24:20 CDT 2008
On Mon, Mar 24, 2008 at 2:41 PM, Jeff Surgeson <solar at 3hex.com> wrote:
> More likely me to be missing something :-(
>
> So you are saying if my default (as setup in solar.config) is "user" and
> my
> only page controller class is Vendor_App_User, with a _action_default of
> list, and with only one action named actionList and I request
> nonexistantclass/listall it will default to user/listall, it will find
> the
> user class but wont find action listall so will run _notFound() instead of
> running user/list?
>
> Why bother to define a default page controller class in config, and
> specify a
> default action in that class if it is not used when the requested
> controller/action is not found?
>
> Sorry but I am obviously missing something rather obvious to everyone
> accept
> me.
Jeff,
I was confused with this behavior initially like you and I had asked a
similar question. Coming from using Zend Framework, I had wanted to know
how to specify the default controller to be invoked when accesing a
project's root URL. In ZF, you would utilize naming convention of a
controller and action to get something to run at the root of a project.
Let's say you had a site hosted at www.mysite.com To get something to run
at that URL, you would create a DefaultController with a method named
indexAction(). When migrating to Solar, I was looking for a way to do the
same and it seemed like specifying the "default" key would do the same.
However, like Antti described, the default attribute causes all non-existent
requests to get forwarded to the default controller as params. This has the
unwanted side-effect of that controller being displayed when accessing
non-existing controller/actions. Paul had mentioned in a reply that he did
this to allow for short URLs. If your default controller does not utilize
any params (which is almost always in my apps), this can seem unintuitive.
Notice if you use Solar_App_Base as an example, the default is set to the
HelloWorld App. If you access the project with an invalid controller, you
will get shown the Hello World text which doesn't seem ideal.
Where this behavior does make sense is if you have a default controller
where you use params. Let's say you have a default controller which accepts
a param which is used to lookup some file off of disk, it retrieves that
text and populates the view with the content.
Now you can have urls like www.mysite.com/param1 instead of
www.mysite.com/default/action/param1
For me, my workaround is to call func_num_arguments() in my default
controller. If it is greater than zero, I forward it to my page controller's
_notFound method. It's not ideal, but I haven't found any better
alternatives.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20080324/31129819/attachment.html
More information about the Solar-talk
mailing list