Modules using: Views, Views Attach, CCK, Nodereference URL

I'm trying to use an argument to hide all posts of a content type that reference another node. I have two content types, Product, and Product Review (PR) with PR referencing Product. I've gone through the settings for both content types numerous times and can't see anything wrong.

The problem I'm having is that setting up the view to display the PR content type shows all posts like normal with no argument. (Expected) Adding the argument Content: Review (field_productref) will hide all posts regardless on every Product page. It's saying there are no nodes associated with any Product and that is false. There are multiple posts for every product.

In the Node Content Settings the argument is set to nid: Use the ID of the Node the view is attached to.

The only fields I have on the PR content type is a Fivestar rating field and the nodereference URL field labeled Reviews. The fields on the Product content type are all the standard fields for an Ubercart Product type. Below I'm posting my export. If you do not see anything wrong with it please let me know and that will at least tell me that my problem lies elsewhere. Perhaps another module or the settings for my content types are incorrect even after checking them over and over.

Thanks for any help with this.

$view = new view;
$view->name = 'Reviews';
$view->description = 'View for printing reviews';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'name' => array(
'label' => 'Name',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '[name]',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 1,
),
'empty' => '',
'hide_empty' => 1,
'empty_zero' => 0,
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'field_rating_rating' => array(
'label' => 'Rating',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 1,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_rating_rating',
'table' => 'node_data_field_rating',
'field' => 'field_rating_rating',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'title' => array(
'label' => 'Title',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'teaser' => array(
'label' => 'Teaser',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 1,
'max_length' => '100',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 1,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'teaser',
'table' => 'node_revisions',
'field' => 'teaser',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'field_productref_nid' => array(
'default_action' => 'not found',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'node',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'field_productref_nid',
'table' => 'node_data_field_productref',
'field' => 'field_productref_nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'6' => 0,
'3' => 0,
'4' => 0,
'5' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '',
'validate_argument_node_type' => array(
'product_review' => 'product_review',
'blog' => 0,
'product' => 0,
'product_kit' => 0,
'forum' => 0,
'comment' => 0,
'page' => 0,
'portfolio' => 0,
'profile' => 0,
'simplenews' => 0,
'story' => 0,
'uprofile' => 0,
'webform' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'4' => 0,
'3' => 0,
'2' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'product_review' => 'product_review',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('items_per_page', 5);
$handler->override_option('use_pager', '0');
$handler->override_option('use_more', 1);
$handler->override_option('use_more_always', 0);
$handler->override_option('use_more_text', 'See All Reviews');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'name' => 'name',
'field_rating_rating' => 'field_rating_rating',
'title' => 'title',
'teaser' => 'teaser',
),
'info' => array(
'name' => array(
'sortable' => 0,
'separator' => '',
),
'field_rating_rating' => array(
'sortable' => 1,
'separator' => '',
),
'title' => array(
'sortable' => 0,
'separator' => '',
),
'teaser' => array(
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('node_content', 'Node content', 'node_content_1');
$handler->override_option('types', array(
'product' => 'product',
));
$handler->override_option('modes', array(
'0' => 'full',
));
$handler->override_option('argument_mode', 'nid');
$handler->override_option('show_title', 0);

Comments

RKS’s picture

Not bumping, but just adding a possible question. Since I'm excluding content based on what's referencing a specific node, I'm assuming there will be no results to show in the live preview? Correct? So checking the actual node page is what's going to show me if anything is wrong.

Could it be that

	print views_embed_view('Reviews');

in the tpl is wrong? This is how I normally embed a view but maybe it's wrong for using arguments and you have to define the argument within the embed? This was just a thought but the only way I know how to embed a view. If this is wrong and there is another way please let me know.

merlinofchaos’s picture

You have to pass the arguments along as additional arguments to views_embed_view(). Also, you need to pass the display ID; by default you get the 'default' display which may or may not be the same as your views attach display.

RKS’s picture

Okay. I see what you're saying. It looks like there were a few more things for me to learn about embedding a view. I wasn't thinking it didn't do it for me. I've tried both of these methods:

	$view = views_get_view('Reviews');
	$myargs = array($field_productref_nid);
	$display = $view->execute_display('node_content_1', $field_productref_nid);
	print $display['content'];

and

print views_embed_view($Reviews, $node_content_1, $field_productref_nid);

with no luck. I don't know which is the preferred method but neither are working. Probably still have it wrong.

mjstone323’s picture

I'm having a similar problem trying to display a view in my tpl.php. Here's the code:

print views_embed_view('list_teach_ref_checks', 'node_content_1');

I've printed out the page with

 print_r($node)

and I can see the view is being output properly otherwise, just not via my template. Nothing at all of the view is displaying, and I'm also not getting any errors.

I used Node Reference to create the view's link in the node. Could there maybe be a conflict?
Everywhere I'm looking it says that views_embed_view is the way to get a view to display in a template. Is there more to it than that code above?

Edit: Answered my own question - I needed to add the argument I was passing in the view (the relationship happening on the parent node's nid) - it's showing up now! Here's my code:

print views_embed_view('list_teach_ref_checks', 'node_content_1',$node->nid);

kars-t’s picture

Status: Active » Fixed

Hi

I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.

Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.

Status: Fixed » Closed (fixed)

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