I regularly need to do things like have a template call a view to pull out other information related to the node being templated (basically this is the concept of views fusion; except fusion is very limited in its capabilities for this).

The views_build_view function has the making of being very useful for this except that none of its options returns the actual fields that are set in the view being called. The page view does return this info but not as usable variables that you can theme within your template - but an already themed html string. The "items" type would seem like the obvious option for this but it doesnt seem to return anything close to the fields that have been defined.

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

Comments

sadeh’s picture

Hi Peter,

I have the same problem here, it looks like when you creating a view and then want to use it in a node with views_build_view function, it JUST use "Full node" from "View type" section, no matter what you have selected here for view type, it keep using the full node.

View module: version = "5.x-1.6"
Drupal : 5.3

Please let m know if you have found any fix for that.

Cheers,
Mehran

tommo’s picture

I couldn't get any of my values out either until i took a look at what exactly it was I was receiving, I did the following to debug:

//This should be within your overriding view theme function in template.php
//...
foreach ($nodes as $node) {
  print('<pre>');
  print_r($node);      
  print('</pre>');
}
//...

Then you'll see exactly what it is you're getting, in my case the only useful thing i was getting were nid so i had to use the node load method to get to what I needed:

//change the debugging function above to:
//...
foreach ($nodes as $node) {
  $nodeobj = node_load(array('nid' => $node->nid));
  //do something with the node ($nodeobj)
}
//...

Hope this helps you.

I have a question though, is the veiws_build_view displaying/running for any other users apart from administrator? I have this issue here : http://drupal.org/node/192655 and could really do with some help too.

Cheers,
Tom

BradleyT’s picture

For my views I have them as blocks that show lists. I too was having issues with views_build_views returning all the information and not the header or footer.

By changing 'embed' to 'block' like so it seems to have fixed the "issue".

//Old
    print (views_build_view('embed', $view_1, $current_view->args, false, false));  

//New
    print (views_build_view('block', $view_1, $current_view->args, false, false));  
merlinofchaos’s picture

I think the original feature request is for something that returns semi-processed field data but without the actual views theming?

Either that or a plugin which utilizes the data is what is needed? Possibly what the original poster wants could be gotten by examining how theme_views_view_list does its magic, and making appropriate views_handle_field calls.

liquidcms’s picture

thanks merlin.. yup.. you are right.. i was looking for something that return my view "list".. i.e the fields as defined in my view with the formatting, etc as defined in my view.

jfall’s picture

I recognize this is a slightly different issue, so perhaps BradleyT and I should file another issue?
I am having the same problem - the "embed" type ignores the view fields selected, and returns the complete node instead. I used the same "fix" and switched to "block", but...

Can someone tell us - is this the intended behaviour of "embed"? If so, is there a handbook page that describes how to theme the results that come back from "embed" to display only a sub-set of the fields? If not, should we post this as a new issue?
thanks.

merlinofchaos’s picture

Status: Active » Closed (won't fix)

This will not be fixed in Views 1.