Like a superhero, you respond to the call of the moon-blue Drupal logo gleaming in the night sky above Gotham. Another chance to use your hard-won expertise in the service of others. The Commissioner directs you to a young man, a relative Drupal Newbie, who is mildly distressed.
The Scene
Drupal 4.6. A tableless CSS theme. A website, being developed for an academic journal, using the Tagnode module, along with Flexinode, to create an Issue-Article structure.
The Problem
You ask the Drupal newbie what went down. "The theme development was going well," he stammers, "and the test site was outputting valid XHTML. The layout looked great. I had a few different flexinode types set up, and some custom blocks. But I was still searching for way to handle the Issue-Article relationship because Taxonomy alone didn't quite do it for me. That's when I found Tagnode." You nod. "It was great," he continues. "It did everything I needed it to do, dynamically linking Issue nodes with Article nodes and making the content creation process easy for my colleagues. I was thrilled, really thrilled. But then I noticed that any nodes affected by tagnode were breaking my layout. They contained an extra </div> that severed my footer!"
"A severed footer," you think to yourself. "Not pretty."
"Well, I set about searching for the culprit. Figured it must have been in Tagnode. Even contacted Tagnode's author, Dado. But Tagnode only introduces four <div>s, and it closes each one of them. I re-checked my theme: everything properly nested, completely symmetrical. Here's the really interesting thing: no other page on my site was affected. Front page, fine. Other nodes, fine. Only the nodes affected by Tagnode have the extra </div>... but the module itself isn't where it's coming from! I thought maybe the problem was that I was building my theme with Smarty. So I ported the entire thing to PHP Template. Same problem."
An Inside Job?
"Is that all?" you ask.
"Well, I did notice one other thing. I'm not sure what it means. The Rogue </div> is appearing from within the <?php print($content) ?> call. I know this because it's inside of the <!-- begin content --> and <!-- end content --> comments, neither of which are in my theme files. I figure it must have to do with the combination of Tagnode with Flexinode, or something like that. But I'm reluctant change any other files, for fear that I'll screw up pages that work. I'm hoping it's just a theme question, but..." His voice trails off. You look up to find him staring into nowhere, looking confused. Suddenly, he looks back at you. "Where do you think it's coming from? What do you think I should do?"
You pause. Your mind scans years of drupalhero experiences as this sad-looking, distraught newbie waits for any sign of hope. Not wanting to let him down, you turn and say...
Comments
Is that my cue?
Is that my cue?
The randomness is inserted by the phptemplate.engine in it's $vars array.
The line is found in themes/engines/phptemplate/phptemplate.engine
However the content is generated from one of the template files, usually node.tpl.php or node-.tpl.php
So check out your node*.tpl.php files for that
tag.
My work here is done.
--
www.bargainspy.co.uk | More Drupal modules
--
Ixis (UK): Drupal support, Drupal hosting.
Node.tpl.php
Yes, but node.tpl.php is all properly nested. If I remove a
</div>from there, it breaks other pages. It's coming from somewhere else...might be related..
Hi czheng..
This may or may not be related, but, I remember looking at a similar problem a while back, i.e. phantom DIVs appearing where they shouldn't and while I didn't get a chance to pinpoint it precisely..I think it had something to do with forms and
form-items.I never got a chance to get to the root of the problem..but, it was a pain.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
aha...
Hi again...
Spotted this missive from Robert Douglas which explains how to override the rogue DIVS in phptemplate....
might be useful
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Just for precisement...
If you use Fleximaxed Flexinode, the problem may be in the layouts of your Flexinode content types. Check that!
Good luck!
The Case of the Dangling Div
Well, tagnode's themable functions only contain pairs of opening/closing tags, so if there is a left-over
</div>it's not likely to come from those.Without some HTML to look at, it's not easily to say though. Does it happen on individual node views, on listings, ...?
You say the div is inside $content, but that could still be anywhere in the page generation process. Compare the
</div>'s location to your node.tpl.php for example. Perhaps you could try adding some extra<!-- markers -->of your own, in the .tpl.php files, and in the tagnode.module's themable functions (the ones that start with theme_).If it happens on node listings, then my guess is that it has something to do with teaser generation. When generating a teaser, Drupal does not pay attention to HTML structure.
PS: Best. Support request. Ever.
Many thanks...
Thanks everyone... lots of possibilities here. I'm going to dig through this and see what I find. First, I think I need to read up on themeable functions, because I don't know what they are or what they do. I'll also take a look at that conversation with Robert Douglass' comments. Then I'll proceed with Steven's suggestion of adding comment markers to try and isolate the problem.
For clarification: I don't use Fleximax, and it happens on node views, not lists or category views.
I'll post back with the results, but it may not be very soon because I've got papers to write for school...
Holy Unbelievably Careless Newbie, Batman!
Yes yes... I found it. And as you might guess, it was pretty silly. It turns out it was in my node.tpl.php. And it wasn't that I had closed more
<div>sthan I'd opened... it was a little more subtle than that. I introduced a custom<div>inside of anifstatement, and closed it outside of that statement. Silly me. Oh well... thanks all for the help. At least it gave me a reason to procrastinate today.