drupal 主题化自定义字段视图:PHP 代码
我有一个名为“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您仅使用视图来创建块,但以其他方式查询数据库、创建标记等,则应考虑在自定义模块中创建块。所有工作都在您已经编写的代码中。这样您就不必考虑视图使用的许多模板,而只需使用
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.