1
votes

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.

5
As many have stated already, the $content variable gets assembled from many sources and is thus hard to debug. Can you post a print_r or var_dump of the $content variable from one of the broken pages? - Henrik Opel

5 Answers

2
votes

$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.

1
votes

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 like hook_nodeapi and hook_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".

1
votes

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.

0
votes

The $content is what is returned from hook_view()

If many nodes are affected it sounds like it could be a custom theme function that is causing the problems.

-1
votes

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.