node.tpl.php 中的 $content 变量 (Drupal 5)
node.tpl.php 中的 print $content
语句导致我的整个布局中断,可能是由于 DIV 嵌套不正确。
我想检查并修复这个问题,但我无法弄清楚 node.tpl.php 文件中 $content
变量的来源是什么/在哪里。
我将不胜感激任何帮助。谢谢。
The print $content
statement in node.tpl.php is causing my whole layout to break probably due to incorrect nesting of DIVs.
I want to check and fix that but I can't figure out what/where is the source of the $content
variable in node.tpl.php file.
I'd appreciate any help. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
$content 是保存所有内容的变量。因此很难通过嵌套的 div 来确定错误的确切位置。
但是,问题很可能出在位于主题或自定义构建模块中的自定义主题函数中。 do 中的模块通常不存在此类错误,因此希望您能够在有限的可能性下快速找到问题。
另一个问题可能出在用于生成某些内容的模板中,同样,您应该只查看主题中的定制模板。
$content is the variable that holds all the content. So it's difficult to pin point the exact location of the error with the nested divs.
However, the problem is most likely in a custom theme function located in your theme or a custom built module. Modules from d.o is usually free of such bugs, so hopefully you should be able to find the problem pretty quickly with the limited possibilities.
Another problem could be in the templates that's used to generate some of the content, again, you should only look at the custom made ones in your theme.
Drupal 节点中的
$content
变量并非来自任何一处。所有启用的模块都可以使用hook_nodeapi
和hook_view
等 Drupal 挂钩添加、删除和调整$content
变量。了解您启用了哪些模块以及导致问题的确切 HTML 可能会帮助人们为您提供更多帮助。按原样,你的问题的答案是“这取决于”。
The
$content
variable in Drupal nodes doesn't come from any one place. All enabled modules are able to add, remove, and tweak the$content
variable, using Drupal hooks likehook_nodeapi
andhook_view
.Knowing what modules you have enabled and the exact HTML that's causing trouble may help people help you more. As-is, the answer to your question is "it depends".
没有一个地方可以成为 $content 的来源,它可以包含几乎任何地方生成的内容。
调试的一种方法是关闭模块,直到问题消失,然后找出该模块中导致问题的原因。
There is no one place which will be the source of $content it can contain generated content from just about anywhere.
A way to debug is to turn off modules until the problem goes away and then work out what in that module is causing the problem.
$content
是从hook_view()
返回的内容。如果许多节点受到影响,听起来可能是导致问题的自定义主题函数。
The
$content
is what is returned fromhook_view()
If many nodes are affected it sounds like it could be a custom theme function that is causing the problems.
尝试使用调试器来查看给定时间包含变量的内容。如果我没记错的话 $content 是当前节点生成的 html 内容。
Try to use a debugger to see what contains the variable at a given time. If I remember correctly $content is the generated html content for the current node.