views:

889

answers:

6

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.

A: 

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.

Elzo Valugi
There are many 'nodes' or 'posts', difficult to debug. I'd rather find and debug the source html.
Nimbuz
A: 

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.

Phil Carter
I just need to find which block/function/file contents is it printing so I can check and fix validation errors. hook_view is in which file? Does it contain html that might have incorrect nesting?
Nimbuz
`hook_view` isn't in a specific file. `hook_view` is a hook that any module can use to add to `$content`. Many modules do different things to `$content`.
ceejayoz
+1  A: 

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.

Jeremy French
Right, thats what I need to know, what nodes does content print and where do I find them to trace the error.
Nimbuz
Any module may have hooks which cause things to appear or change in $content. As a result of this $content can contain just about anything. Generally it will be custom ones which cause the error but not always. Once you have isolated the module you will probably be able to see what has caused the issue. ps why the downvote?
Jeremy French
+2  A: 

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

googletorp
+1  A: 

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

ceejayoz
A: 

although $node->content is assembled in hook_view and hook_nodeapi there must be a place where the arrays in $node->content are placed in the $content string variable used by most themes. Does somebody know where that takes place?

Joi