I am having trouble with the views_build_view method (in drupal 5.3). I've created a node-gallery.tpl.php file that runs the method invoking the embed feature for a view that returns an image as a link to the node. It works fine when I'm logged in as administrator but won't work at all i.e. dosn't display anything under any other user.
I have tried to set and unset user permissions in both the view itself and under 'views module->access all views' in the access control section... no combinations have worked.
here is the code from the tpl.php:
$view = views_get_view('portfolio_grid');
print views_build_view('embed', $view, array(), false, 10);
Any ideas?
Tom
Comments
Comment #1
tommo commentedAfter some more testing this is only happening when the views_build_view is called from within a cck tpl file.
If you create the body with php input type and put it directly in it's fine but this leaves the body input open to php.
Better than that is to create a php bloc and put the code in that only displaying it on relevant page.
It seems to me there are quite a few issues with using views on cck nodes or did I just try to do something silly?
Comment #2
merlinofchaos commentedHmm. There are very few things in Views that would cause it to do this; and your finding that it only happens within a CCK template file is even stranger. It doesn't appear to me that you did something silly; what you say you are doing makes sense to me as a good approach, at least on the surface.
1) Are you sure the code is running at all when this happens?
2) Using devel.module you can watch the query log and examine the actual query that's happening? It's possible that something is rewriting the query in a very specific instance? (This is odd but checking the query that is actually run is a good first thing to check).
Comment #3
merlinofchaos commentedWill not be fixed in Views 1.