So eaton and I just stumbled across an interesting issue that we're not quite sure how to solve.
Right now when attaching a view to a node (and a user profile), the display is generated via $view->execute_display() and the raw results are then stuck into the $node->content array as an item type, because that gives us a #title property. However, item assumes that it's part of a form and therefore we get form HTML, such as "label". That is ungood.
We also realized that when we ask Views for the display template in the Theme:information window, we get a PHP error because views_attach does not in fact provide a template file at all, and views tries to look for views_view.tpl.php in the views_attach directory. That is ungood.
So... what is actually happening? Is the template file simply bypassed because we're calling execute_display()? Is it falling back to the views-default template? It would seem to, since attached displays work. But then why are we getting an error? On top of that, there's still the issue with the title being poorly placed.
So the working theory is to add a template file that is a clone of views-view.tpl.php but also has place to put the $title in there if set, which is only set if the user checks the appropriate checkbox. And then... do we switch to views_embed_view(), or is execute_display() correct? We're not actually sure.
Help us, merlin, help us!
Comment | File | Size | Author |
---|---|---|---|
#3 | views_attach-theme.patch | 5.45 KB | Anonymous (not verified) |
#2 | views_attach-theme.patch | 8.7 KB | Anonymous (not verified) |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedYou'd stick with execute_display(). As a display, you have the right and privilege of registering a theme function. You'd probably register views_attach_view or something along those lines.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedThe last patch had mistakes. Check this one out instead.
Comment #4
gleroux02 CreditAttribution: gleroux02 commentedI applied the patch, and the tpl is working. The only problem that I am having is that when I try to copy the tpl out into a theme directory to make changes to it, views picks up the new tpl file but the view does not print. When I took a look at $variables the view object was still there, but rows and everything else that gets printed in the tpl were not.
Comment #5
PasqualleViews: #473786: Automatic theme template suggestion for new display types
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedPasqualle, are you saying that this is an issue for this patch or is this a larger Views issue?
Comment #7
PasqualleI am saying that views module should be able to suggest the template names for new display types. I think it has all the info for the correct template names. So, I would try to fix the issue in views..
Comment #8
Crell CreditAttribution: Crell commentedThere's other issues that this patch addresses such as the title handling, so I'm inclined to go ahead with it anyway even if Views gets updated later.
Comment #9
eabrand CreditAttribution: eabrand commentedWhen in doubt, flush the whole cache, not just the theme registry.
Comment #10
Crell CreditAttribution: Crell commentedSage advise. :-) Committed. Thanks all!
The next step is probably to do the same for the user profile display, since it's also missing a template.
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedUm. You cloned views-view.tpl.php? That's probably not good.
'theme path' might have been a better choice.
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedOh well you have a $title in your display so of course you have a clone. Sorry, people in another queue are doing the wrong thing due to this example. =)