如何在 drupal 中设置视图主题

发布于 2024-08-19 14:48:54 字数 54 浏览 6 评论 0原文

任何人都可以帮助我了解如何主题视图。

对于创建的每个视图,我想要有不同的模板。

Can any one help me out on how to theme a view.

For each view created i want to have different templates.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冷情妓 2024-08-26 14:48:54

主题视图可能有些棘手,具体取决于您创建的视图类型和需要进行的更改。查看此 Views 2 简介,并确保安装高级帮助模块从视图模块本身获取views2文档(将有一个指向有关视图概述和文档的链接)编辑页面(激活高级帮助模块后)。

您还可以在此处找到一些问题/答案(例如 Drupal 6:如何快速主题化视图?),如果你搜索一下。

Theming views can be somewhat tricky, depending on the kind of views you have created and the changes you need to make. Check out this introduction for Views 2, and make sure to install the Advanced Help module to get at the views2 documentation from the views module itself (there will be a link to the documentation on your views overview and edit pages, once you activated the Advanced Help module).

You can also find some questions/answers here on SO (e.g. Drupal 6: How to quickly theme a view?), if you search a bit.

守护在此方 2024-08-26 14:48:54

前几天我确实这样做了。我将向您提供一个简短的概述,并在稍后进行扩展。

  1. 设置您的视图;通过转到视图 ->添加视图
  2. 一旦,您的视图完全设置完毕,在视图的底部(D6 中的左栏,D7 中最右侧的“高级”栏),您将看到一个名为“主题:信息”的链接,单击它。
  3. 您将看到一个模板 (.tpl.php) 文件列表,视图使用这些文件来主题化您的数据。基本上,加粗的文件名是用于主题数据的文件视图。

自定义您的视图

  1. 选择您需要主题化的页面。例如,如果您创建了一个“块”视图,并且我想自定义基本 html 布局,我会选择一个正在向我显示的名称(当前粗体的名称除外)并在我的主题中创建该文件 view-fields-views.tpl.php) - 这是如果视图告诉我可以使用文件名 custom-file-view-fields-views.tpl.php
  2. 目录 (sites/all/zen/custom-file - 步骤是知道您需要在其中放入什么代码。最快的方法是返回视图中的主题信息,单击要替换的文件的链接并获取向您显示的代码。将该代码粘贴到您创建的文件中。
  3. 从现在开始,您现在可以成功自定义该视图。

请记住,向您呈现的主题信息是从基本到复杂(从上到下)呈现的。因此,请仔细选择您需要编辑的文件。稍后我会在这个答案中放一些图片。

希望这有帮助!干杯!

I actually did this the other day. Ill give you a brief overview and expand a little later.

  1. Set up your view; by going to Views -> Add View
  2. Once, your view is completely set up, at the bottom of the view (left column in D6, right-most "Advanced" column in D7), you will see a link called "Theme: Information", click on it.
  3. What you will be presented with is a list of templates (.tpl.php) files that the views uses to theme your data. Basically the file names that are bolded are the files views is using to theme the data.

To Customize Your Views

  1. Select the page you need to theme. For Example, if you created a "Block" view, and I wanted to customize the basic html layout, I would pick a name (other than the one that is currently bolded) that is being displayed to me and create the file in my themes directory (sites/all/zen/custom-file-view-fields-views.tpl.php) - this is if views told me that I could use the filename custom-file-view-fields-views.tpl.php
  2. The next step is knowing what code you need to put in there. The quickest way, is to go back to the theming information in views, click on the link of the file your replacing and grab the code that is presented to you. Paste that code in the file you created.
  3. From here on out, you can now successfully customize that view.

Keep in mind that the theming information presented to you is presented from basic to complex (up to down). So choose which file you need to edit carefully. Ill put up some images in this answer a little later.

Hope this helps! Cheers!

泡沫很甜 2024-08-26 14:48:54

您有什么具体的目标想要完成吗?有很多方法可以对视图进行“主题化”,除非您指的是严格的 Drupal 意义上的“主题”。

就我个人而言,我只是给字段类并使用它们,如果需要的话重写输出以将变量包含为类。这比直接修改 TPL 文件更容易且更易于管理。

Is there something specific you're trying to accomplish? There's a lot of ways to "theme" a view, unless you mean "theme" in the strict Drupal sense.

Personally I just give the fields classes and use those, rewriting the output to include variables as classes if need be. This tends to be easier and more manageable than modifying TPL files directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文