I've been having this problem where views attach won't render on my nodes. The only views attach output I'd see is:

<div id="-" class="view view- view-id- view-display-id- view-dom-id-"> </div>

I've tracked the problem down to node types that don't have a body. I'm using a module defined node type where 'has_body' is FALSE. Another node type is one created in the Drupal UI with an empty body field label.

If I enable the body, clear the cache, and view my node, the attached views appear.

If I disable the body and view my node, the attached views are not there.

Comments

Anonymous’s picture

FYI: My views are configured to display on the 'Full node' build mode.

Crell’s picture

That is highly weird, since we never use body fields, ever, and views_attach works fine. :-( Although we've not tried it on module-defined node types. Can you confirm that it's just module-defined node types that are an issue?

Anonymous’s picture

I'm willing to believe that it is highly weird then. What is the emoticon for pulling out one's own hair? ;-)

Anonymous’s picture

Title: Views attach don't display when node type has no body. » Views attach don't display when theme overrides default templates.

Merlinofchaos helped me track down the essential problem here, and it has a workaround. It has absolutely nothing to do with title-less node types, so I'm changing the title of this issue.

The template_preprocess functions are not being called by Drupal's theme layer when the active theme has overrides for the templates. I put "die();" at the top of views_attach.theme.inc after clearing and reconstructing the drupal cache, and my request was processed correctly, which tells me that views_attach.theme.inc isn't loading when the .tpl.php have been overridden.

A workaround:

Copy the template_preprocess_views_attach_display_node_content_view and template_preprocess_views_attach_display_profile_view from views_attach.theme.inc and put them into your theme's template.php. Rename them as necessary.

Crell’s picture

Ugh, I think I've seen that issue before. I spent a while tracking down something similar to the theme discovery system in core. I could have sworn I posted an issue about it somewhere, as I couldn't work out exactly what the correct fix was, but I can't find it at the moment.

I'm leaving this issue open for documentation purposes for now, but I don't think it's a bug in views_attach per se but with core's theme system.

nicholasthompson’s picture

Just to add - I'm experiencing the same problem with a purely CCK formed node type. It works the first time from a clean cache, but the second time I get an empty DIV with no data in it...

I'll try copying the preprocess stuff..

nicholasthompson’s picture

I can confirm that copying the two preprocess functions mentioned above from views_attach.theme.inc into your own template.php (and renaming the functions appropriately) works fine.

What an odd issues - I've not seen anything else in Drupal 6's theme layer that suffers the same problems...

socialnicheguru’s picture

facing a similar issue. thanks!

rhache’s picture

Also encountered this.

I only had this happening once I created a tpl override for a node content display.

Thanks,
Rene

Crell’s picture

To those having this problem: If you move the preprocess function to your .module file, does the problem go away?

Anonymous’s picture

Crell:

Yes. I didn't propose this because it's hacking the module. Having the template_preprocess functions in the module file means they're loaded anyway.

Crell’s picture

Yes. My point is that if that works, it means this is definitely the previously mentioned bug in the theme system. I don't know how to fix said bug, sadly, but it means that's likely the root cause. :-)

nachenko’s picture

I can confirm the problem is that given certain conditions, the system doesn't include attach_views.theme.inc file. This code:

include_once('views_attach.theme.inc');

in views_attach.module file, line 95 (inside hook_nodeapi implementation) fixes (workarounds, I'd better say) the problem.

Crell’s picture

#591804: Theme registry build bug: External file with template_preprocess is not loaded if tpl.php is copied into theme is the problem in core. I thought I'd submitted an issue for it, but looks like rfay did as well. :-) That's where this needs to get fixed.

Crell’s picture

#489254: theme file not getting included - Ah, here's the issue I had submitted on the same subject.

Crell’s picture

Status: Active » Fixed

So I've confirmed that this is a core bug, and the fix has nothing to do with views_attach. Therefore I'm marking this as fixed, since from the views_attach standpoint it is and I want to keep my issue queue clean. :-)

Until this gets fixed in core, the patch mentioned in #14 works perfectly for me.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

owntheweb’s picture

Sorry to bug on this. I'm in the same boat with my node-speaker.tpl.php. I don't have patch abilities readily available. Using the option from #4. How would I rename the functions if my theme name/folder is happytheme? A happy theme and views_attach showing up on the page would make me happy. I am able to get results in the view preview and node edit page, just not the full node.

happytheme_preprocess_views_attach_display_node_content_view?

Thank you,

Chris

(I'll leave this issue 'closed')

emi_bcn’s picture

Status: Closed (fixed) » Active

Hello there,
I'm also using this great module, and I'm having troubles too. My scenario:

  • I have three special content types: representations, discussions and photo albums
  • I've made two node relationship: a CCK field inside discussions and photo-albums that links to representations
  • I've also made a View Attached to content of type discussion for each relationship (2 views attached to one content type)
  • I've made a template for full nodes of type photo album and another template for the view of photo-album attached (views-attach-display-node-content-view--photo-album.tpl.php)
  • When I see a representation with no album, it shows everything correctly (discussions included correctly)
  • When I see a representation with photos, it shows anything (Page not found, neither the representation, neither both views attached)
  • When I see a node of type photo album (which has a themed template), it shows the same as before: Page not found. This error gave me lots of headaches.
  • Both "Page not found" errors take longer time to render that any other page on the site. These errors only raise when
    1. there is a view attached to representations
    2. that view shows templated nodes: I've tried to delete the template. After flushing caches, disabled the relationship on the view (associating this view to other contents not in here), controlled that the affected nodes are shown correctly and re-enabled the view: the error persists.
    3. full node Row Style: Tried to change the other view attached I have (with Fields row style and without template) to show as Node row style, and continued to show correctly. Tried some clicks to see if caches affected, and not. Tried to reflush all caches and anything changed: everything running as expected.
    4. ¿node with a multiple CCK image field?: It's too late to go on debugging this...

I've tried the workaround on comment #13, but it's still doing the same. I'd like to test #4's, but I'm completely unsure as how the function must be named. I've reopened the issue just wondering if someone sees it and answers to me and to #18's.

I've also tried to do something with Devel module, but when it's enabled, the desired pages take too much memory (I've raised it to 128MB and still going out of memory).

I've tried too the patch posted at #591804: Theme registry build bug: External file with template_preprocess is not loaded if tpl.php is copied into theme, but no luck.

I've posted this to give more information about the problem, if needed or if someone wants to resend this info to #591804: Theme registry build bug: External file with template_preprocess is not loaded if tpl.php is copied into theme.

Thanks a lot by this great job!!
emi

Edit:
Some more info into the scenario. It's del'ed or bold.

Anonymous’s picture

Status: Active » Fixed

emi bcn:

The rules for naming theme functions, templates and preprocess functions is documented here http://drupal.org/node/223430

The symptoms of the original bug were never ever 404 errors and fatal errors of crossing the PHP memory limit. It sounds like you have a combination of problems.

Please do not re-open a closed issue to report complex trouble like this. When you've got a Drupal syndrome like this, your best option is to seek support in the forums, IRC or local support in your community. Politely ask for help diagnosing the problem. If you can narrow down the problem to a NEW bug or undocumented support request, file an issue.

emi_bcn’s picture

Hi again!
Thanks for the info and sorry for opening the issue again, just trying to get the requested info.

I have debugged the problem, it's related to nodereference CCK field presentation merged with attached_views. It tries to show full node "referenced" node inside all nodes in the attached view, what, depending on your configuration, it calls attached view again for every node it shows on. Here it is: infinite recursion of nodes.

If someone has the same problem: go to your referer content type (the one which has a CCK field referencing to the other one) "Manage fields" tab and switch all visibilities to hidden (or just the one you use on your attached view). This will prevent infinite recursion.

Module maintainers: May be views_attach should be aware of this and alert you if it detects this infinite recursion problem. If not, at least mention this possibility on some part of the docs. Consider open an issue yourself.

See you!!
emi

Crell’s picture

emi_bcn: Do not post new issues into an existing queue. Your issue has nothing to do with this thread, and it is simply noise. Post a new issue if you need.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.