I have a View that returns "The most recent node that contains a node reference to the given node".

This works fine as a page View at the URL- node/$arg/myview, e.g.: node/12345/myview.

However if i try to call it using PHP code embedded in an FCK text field (in PHP mode) with this code-

<?php
$view_name = 'myview'; //name of view
$limit = 1; // number of returns
$view_args = array(12345);
$view = views_get_view($view_name);
print views_build_view('embed', $view, $view_args, TRUE, $limit);
?>

It produces no output.

This could be because-

1) Although the node id 12345 works when passed via the URL, it needs to be converted into a
node reference when passed via PHP.
2) Views expecting a '$arg' in the middle of the URL expect their arguments passed differently.

Can anyone give me a clude where I should be looking?

Comments

nevets’s picture

A couple of things to try, add lines of the form step 1<br /> between lines of the script and see what prints.

After $view = views_get_view($view_name); add print "<pre>" . print_r($view, TRUE) . "</pre>" and make sure a view was actually returned (ie is the view name correct).