Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
layout.html的web2py控制器_Html_Web2py - Fatal编程技术网

layout.html的web2py控制器

layout.html的web2py控制器,html,web2py,Html,Web2py,我正在使用web2py构建一个web应用程序,目前已经在一些视图/页面上实现了搜索,方法是在适当的控制器中创建一个函数,然后使用{{=form}}在我的HTML页面中呈现它,如下所示 <h3>Search</h3> {{=form}} {{if results:}} <h3>Results</h3> {{for result in results:}} {{=A(result.title)}} {{pass}} 搜索 {{=形式} {

我正在使用web2py构建一个web应用程序,目前已经在一些视图/页面上实现了搜索,方法是在适当的控制器中创建一个函数,然后使用{{=form}}在我的HTML页面中呈现它,如下所示

<h3>Search</h3>    
{{=form}}

{{if results:}}
<h3>Results</h3>

{{for result in results:}}
{{=A(result.title)}}
{{pass}}
搜索
{{=形式}
{{如果结果:}}
结果
{{对于结果中的结果:}
{{=A(result.title)}
{{pass}}
与在多个页面中重复此功能不同,我希望在layout.html文件中有一个搜索字段,然后可以在所有视图中使用该字段。但是,layout.html没有控制器。是否可以在layout.html页面的另一个控制器中使用方法,或者是否有另一种方法将控制器链接到layout.html,而我缺少这种方法


谢谢。

您能提供更多关于表格的详细信息吗?它是搜索数据库表,还是通过其他方式生成结果?我理解您的问题:您可以定义调用和返回结果的方法。如
返回结果()
。因此,您可以随时使用包含在
layout.html
中的部分html视图。另外,
layout.html
只是应用程序的基本html结构(也称为页面布局)。不要将其视为“页面”。