2009年3月24日星期二

[fw-mvc] RE: re[fw-mvc] write routing, and Zend forms, oh my....

I sort of discovered the answer to my first question. I haven't actually
solved how to do it with ZF, but I recalled where I thought I had seen
this before.

If you use mod_rewrite, you can redirect instead of rewriting. This is
actually the reverse of what ZF assumes out of mod_rewrite. Typically,
you take a url of <host>/<baseurl>/<controller>/<action>, and rewrite it
to index.php. The attributes are passed to index.php as part of the
request, even though it isn't passed technically as a url (since the URL
is rewritten before being processed by index.php).

Redirecting as a R=301 with mod_rewrite would allow you to do the exact
opposite. If you were to roll your own framework, you could build it to
take the action and controller from session variables, so you wouldn't
need the url to direct the front controller. If you did that, you could
actually use the redirect to always turn any request to the app as a
simple <host>/<app>/ making all the controller/action logic hidden from
the user.

And the idea of using frames is also very good, and would allow the same
thing.



--Seth

-----Original Message-----
From: lightflowmark [mailto:1@lightflowinterrupted.com]
Sent: Tuesday, March 24, 2009 5:10 AM
To: fw-mvc@lists.zend.com
Subject: Re: re[fw-mvc] write routing, and Zend forms, oh my....


I can't see how you'd do the first bit other than through Ajax - ZF
determines the controller & action through the URL. You could write a
custom router that would interpret URLs like
mysite.com/app?action=someAction&controller=someController but I don't
think that's what you're after.

Custom validators are the way forward:
http://framework.zend.com/manual/en/zend.validate.writing_validators.htm
l

Brenton Alker-3 wrote:
>
> Seth Atkins wrote:
>> Folks,
>> I have a couple of different questions that I'm not easily finding an

>> answer to in the docs, since the docs are oriented toward documenting

>> specific items in the framework, and I'm trying to figure out how to
>> put different things together as a solution, and lacking examples
>>
>> 1) How can I get the the framework to essentially show null in the
>> browser address bar? For example, the user clicks a link, lets say
>> "mysite.com/app/controller/action/param1/value". I want the address
>> bar to actually look as if they are still at the root level of the
>> app, namely "mysite.com/app". I know I can do this with redirects,
>> but that would create other issues, like when I want a form to post
>> back to itself. Redirecting to "/" would take them to a different
>> page, obviously.
>>
>> I'm sure the answer has something to do with the rewrite router, but
>> I can't find the solution to this issue clearly documented in the
docs.
>
> I'm not sure you can do this, with or without ZF (also don't know why
> you would want to). Other than either doing all your routing based on
> cookies or session data instead of the url (yuck), or fetching all
> content via Ajax. But maybe I'm misunderstanding, have you got an
> example of a page that does this?
>
>> 2) Another issue I can't seem to find an answer to is how to validate

>> a form based on data in the database. For example, suppose I want to
>> have a registration page. With Zend_Form and it's validators, I can
>> easily validate based on if the input is alpha numeric, etc. But the
>> native validators don't seem to have functionality that can query the

>> database to see if the name exists and generate a form validation
>> error based on the results. I could obviously put constraints on the
>> table to enforce unique entries, but that would just generate SQL
>> errors. I want the form to show the user what the problem is when it
posts back to itself.
>>
>> Is the answer to create a custom Validator? If so, are there any
>> examples of how to do this?
>
> Yes, custom validators are the way to go.
>
>> Regards,
>> Seth
>
>
> --
>
> Brenton Alker
> PHP Developer - Brisbane, Australia
>
> http://blog.tekerson.com/
>
>
>
>

--
View this message in context:
http://www.nabble.com/rewrite-routing%2C-and-Zend-forms%2C-oh-my....-tp2
2667776p22677291.html

Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: