drupal 主题化自定义字段视图:PHP 代码

发布于 2024-09-07 13:31:57 字数 316 浏览 2 评论 0原文

我有一个名为“contests_slider”的视图,带有块显示。我隐藏了所有字段并使用“自定义字段:PHP 代码”字段来调用名为 display_front_contests() 的函数。在该函数中,查询数据库并构建一些 html 并返回它。我正在块中显示输出。问题是 Drupal 添加了很多我不想要的额外 div。我转到“主题:信息”并将主题“views-view-field.tpl.php”复制到“views-view-field--contests-slider--block-1--phpcode.tpl.php”并放入只是:在其中,它仍然输出所有额外的 html。 有什么想法吗?我使用了错误的模板吗?

I have a view called "contests_slider" with a block display. I'm hiding all fields and using a "Customfield: PHP code" field instead which calls a function called display_front_contests(). In that function, querying the database and building some html and returning it. I'm displaying the output in a block. The problem is Drupal is adding alot of extra divs that I don't want. I went to "Theme: Information" and copied the theme "views-view-field.tpl.php" to "views-view-field--contests-slider--block-1--phpcode.tpl.php" and put just: in it and it's still outputting all the extra html.
Any ideas? am I using the wrong template?

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

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

发布评论

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

评论(1

弱骨蛰伏 2024-09-14 13:31:57

如果您仅使用视图来创建块,但以其他方式查询数据库、创建标记等,则应考虑在自定义模块中创建块。所有工作都在您已经编写的代码中。这样您就不必考虑视图使用的许多模板,而只需使用 block.tpl.php

请查看 hook_block 了解如何使用去做它。

If you are only using views to create a block, but otherwise query the datebase, create the markup etc, you should consider making a block in a custom module. All the work is in the code you have already written. That way you wont have to think about the many templates that views uses, but instead you'll just use the block.tpl.php.

Take a look at hook_block for info on how to do it.

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