You've got it somewhat backwards -- views don't have controller functions
-- controller functions have views. In other words, URLs that come into
web2py do not specify a particular view being requested but instead specify
a particular controller and function. Typically the function will then have
an associated view, and that view itself may then extend or include other
views. The extended and included views are typically not associated with
other functions but are there specifically to be extended or included. A
layout.html view, therefore, is not associated with any controller function
-- it is just used by other views to fill out common parts of the page so
those views don't have to repeat the same template code over and over.
If you want to have a search box in the layout, you'll have to create a
search function in a controller. Then in the form HTML in the layout,
specify the URL of the search function as the "action" attribute of the
form. When the form is submitted, it will request the search function URL,
and the search results page will load in the browser.
In the layout:
<form action="{{=URL('default', 'search')}} enctype="multipart/form-data"
method="GET">
In the default.py controller:
def search():
[process the search request]
return dict(...)
Anthony
On Thursday, May 9, 2013 7:52:07 PM UTC-4, Bob Babby wrote:
>
> I want to add a search bar to my all my pages. I think the best way to do
> this is by adding it to the layout.html from which all my other html views
> extend from.
>
> The problem I can't figure out is where to put the corresponding
> controller function. For all the other views, the controller functions are
> in default.py. Where would I put the controller logic for layout.html so
> that I can begin building the form using the htmlhelpers?
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.