Drupal Views2 公开表单
不久前,您评论了发帖者有关如何更改 Drupal Views2 公开表单的问题。 在帖子中您提到:
更改主题的正确方法是覆盖主题文件夹中的views-exposed-form.tpl 文件。请记住,这将适用于所有公开的过滤器表单,要主题特定的过滤器表单,您将需要为该文件名使用不同的名称,例如:
views-exposed-form--TITLE--DISPLAY.tpl.php
views-exposed-form--TITLE.tpl.php以及其他一些,您可以检查视图的主题:信息部分以了解模板命名约定。
您能详细说明一下“TITLE”和“DISPLAY”到底是什么吗?两个模板文件都需要还是只需要其中之一?
谢谢。
A while back you commented on a poster's question for how to alter the Drupal Views2 Exposed Form. In the post you mentioned:
The proper way of changing the theme would be to override the views-exposed-form.tpl file in your theme's folder. Bear in mind that this will apply to all exposed filter forms, to theme a specific one, you will need to use a different name for that filename, like:
views-exposed-form--TITLE--DISPLAY.tpl.php
views-exposed-form--TITLE.tpl.phpand some others, you can check the Theme: Information section of your views for template naming conventions.
Can you expand on what the 'TITLE' and 'DISPLAY' are exactly? Are both template files needed or just one of them?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不是你提到的帖子的作者,但我可以回答这个问题。
视图主题的工作方式是,输出的特定部分有一个基本模板,并且可以通过向其添加其他限定符来使该基本模板更加具体。
如果您将
/sites/all/modules/views/theme/views-exposed-form.tpl.php
复制到主题文件夹(或从安装了 Views 的任何位置),并对副本进行了更改,然后编辑您的视图并选择主题:信息并单击重新扫描模板文件,视图现在将使用主题文件夹中的此模板来呈现公开的过滤器表单。这是基本模板名称,因此它将用于每个视图的公开过滤器表单。如果您所做的更改应该应用于每个公开的过滤器表单,那么您就完成了。但是,您可能希望将此覆盖模板文件限制为特定视图,甚至特定视图的特定显示。如果您只想将模板应用到名为 testview 的视图,那么您可以将主题的
views-exposed-form.tpl.php
重命名为views-exposed-form--testview.tpl。 php
.每次重命名或新建文件后,请不要忘记使用“重新扫描模板文件”按钮。现在该模板仅适用于视图 testview 及其所有显示。一个视图可以有多个显示 - 可能是一个块、一个页面、一个管理员页面等。这些显示在视图的编辑页面左侧垂直下方列出。您可以获得更具体的信息并针对特定视图的特定显示。为此,您可以将此模板文件命名为
views-exposed-form--testview--page-1.tpl.php
这将导致它仅用于 testview 视图,并且仅用于该视图的第一页显示。您可以通过将鼠标悬停在选项卡上来找到显示名称 - 它将显示在浏览器状态中显示的 URL 末尾(默认、page_1 等)。只需记住将模板文件名中的下划线转换为连字符:使用 page-1 而不是 page_1。您还可以定位所有页面,例如:
views-exposed-form--testview--page.tpl.php
。这些命名约定以及可以覆盖的模板列表可在此处找到:http://views.doc.logrus.com/< /a>(单击“查看模板文件”)。
因此,如果您想要覆盖默认模板的特定显示或视图,那么您只需要针对该组合的单个文件。如果您需要定位其他视图或显示组合,您将拥有更多文件。
I am not the author of the post you are referring to, but I can answer this question.
The way Views theming works is that there is a base template for a specific part of the output and this base template can be made more specific by adding additional qualifiers to it.
If you copied
/sites/all/modules/views/theme/views-exposed-form.tpl.php
to your theme folder (or from wherever you have Views installed), made changes to the copy, and then edited your view and chose Theme: Information and clicked Rescan Template Files, Views would now use this template in your theme folder for rendering the exposed filters form. This is the base template name and so it will be used for every view's exposed filters form.If the change you're making should be applied to every exposed filters form then you're done. However you probably want to limit this overriden template file to specific views or even specific displays of specific views. If you want to apply the template only to a view named testview then you could rename your theme's
views-exposed-form.tpl.php
toviews-exposed-form--testview.tpl.php
. Don't forget to use the Rescan Template Files button after each rename or new file. Now that template only applies to the view testview and all of its displays.A view can have multiple displays - maybe a block, a page, a page for admins, etc. These are listed vertically down the left side of the edit page for a view. You can get more specific and target a particular display of a particular view. To do this, you might name this template file
views-exposed-form--testview--page-1.tpl.php
which would cause it only to be used for the testview view and only for the first page display of that view. You can find the display name by hovering over the tab - it will appear at the end of the URL your browser shows in the status (default, page_1, etc). Just remember to turn underscores to hyphens in the template filenames: use page-1 not page_1.You can also target all pages for example:
views-exposed-form--testview--page.tpl.php
.These naming conventions as well as a list of templates which can be overriden are available here: http://views.doc.logrus.com/ (click Views Template Files).
So, if you have a specific display or view where you want to override the default template then you only need a single file targeted for that combination. If you need to target additional views or display combinations, you will have more files.
您可以尝试视图公开表单布局模块来获取公开表单主题的视图。
You can try Views exposed form layout module for views exposed form theming.