Simple question about views & controllers, implementing a search function

lingfish

Joined: 2007-05-06
Posts: 11
Posted: Tue, 2008-09-09 09:56

Hi all,

(Tried to ask this on IRC, but the downsize to living in Australia is timezones :/)

I'm in the process of developing a spamclean module -- I know akismet is coming, but I think there's been enough noise out on the wire for something like this, that I'd give it a go.

My summary: a lot of programming experience, not so much in OO languages, zero work done with the Gallery framework before.

At this stage, all I want to implement is a view that gives a search box, submits, and returns search results from comments. I've gotten the search to work fine by using GalleryCommentSearch::search, but I'm confused about how to implement the form.

My question is this, for a simple "give form, submit form, return results to the user" situation, is a controller even necessary? Should I just do all of the work in the view, with appropriate detection of states of user interaction done in the template?

In the future, the plugin will of course allow the user to mass delete spammy comments and more, which of course belongs in a controller... but I'm lost as to how to return search results to a view, from a controller, and think I'm over-complicating things.

Thanks for your help.

 
alecmyers

Joined: 2006-08-01
Posts: 4338
Posted: Tue, 2008-09-09 10:29
Quote:
I'm confused about how to implement the form.

Please see

http://codex.gallery2.org/Gallery2:MVC_Structure

and

http://codex.gallery2.org/Gallery2:Forms

Quote:
My question is this, for a simple "give form, submit form, return results to the user" situation, is a controller even necessary?

Absolutely necessary, yes. Forms submit to controllers.

Quote:
Should I just do all of the work in the view, with appropriate detection of states of user interaction done in the template?

Views don't do work, they fetch things from the database and set up data structures for the template to display.