I've searched and searched - but maybe I'm just not using the correct terms. I'm thinking this is a common issue:
- I've created a form that enables me to enter all the info for my articles.
- I want to offer my readers a "you may also want to read" link to another, relevant article
- So, on that form I need to create a selection list that allows me to choose from a list of all articles - excepting the current article (the one I'm entering at the moment). In other words, every article title would be listed in that list except the one I'm currently editing.

I can use "content types that can be referenced" and choosing the "article" type - but that lists all articles, including the current one.
I've tried using "Advanced - Nodes that can be referenced" - and creating a view for it - but I'm stumped about the "view arguments" entry if that's what I'm supposed to be using to send the variable to the view. I can't seem to find any documentation on what to enter there (or if that's the correct route in the first place).

Is there a module I could use to create a restricted dropdown list - or some other simple fix for this I'm missing?

Comments

mradcliffe’s picture

You could use Content Recommendation Engine or Related Content if you want more fine-grained control over which node should be related to another. It sounds like you want to setup the relationships/relevancy yourself so the latter is probably what you want.

khosman’s picture

Thanks much for the info but... I tried "Related Content" - but it insists on tagging my articles with entirely too much info (despite its option settings).

I just want to create a dropdown/select list that lists all article titles except for the article I'm currently editing, example:

I've got the following article titles: "Apples," "Pears," and "Peaches." I'm editing the "Pears" page and want to see a list containing "Apples" and "Peaches."

When creating a field in "content types" I can select "Content types that can be referenced" - but I get all articles listed in the dropdown. Choosing the "advanced - nodes that can be referenced" wants an argument to pass to the view - but I have no idea how to enter the argument. Has anybody happened upon documentation on how to use that section?

WorldFallz’s picture

You need to add an argument for "node: nid", then select provide default argument, then node id from url, then "exclude the argument" (at the very bottom). That should create the view you want.

khosman’s picture

And if I then want to populate a dropdown/select list on a particular field in a content type using that view, how would I pass the respective node id/argument?

I can populate that list by choosing the "content type" "that can be referenced" - but that puts everything in that list, including the node I'm editing.

I'm assuming I'm supposed to be using the "advanced - nodes that can be referenced" below that - (?) - but the "view arguments" field has got me stumped. I read somewhere online that only static variables can be passed from there, which would knock out the use of this area for my purposes - and if that's the case, what is the standard method for populating that field with exclusions? Surely there must be some way to create a list that excludes the mode I'm currently editing and I'm just missing the forest for the trees...

WorldFallz’s picture

yep, you use the advanced option where you can specify the view-- because you've set up the view with a default argument i don't think you need to put anything there. try it and see if it works.

khosman’s picture

When I do that, the resulting dropdown lists the field titles without any data. When I test the "live preview" of the view (by entering the node id), the query works fine. I'm assuming that the dropdown is simply not "getting" the arugment (node id).

For what it's worth, this the url for an example page I'd use to edit an article, a page I'd expect to see the populated dropdown:
http://localhost/node/16/edit?destination=admin%2Fcontent%2Fnode

The id of 16 appears there - but how to feed it to the dropdown?

WorldFallz’s picture

"localhost" links are on your actual system and so can't be accessed by someone else.

Not sure what the problem is, I just tested this and it seems to work fine:

$view = new view;
$view->name = 'all_stories_except_current';
$view->description = '';
$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(
  'title' => array(
    'label' => '',
    '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,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'title' => array(
    'order' => 'ASC',
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'nid' => array(
    'default_action' => 'default',
    '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' => 1,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'blog' => 0,
      'forum' => 0,
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_is_member' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'story' => 'story',
    ),
    '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',
));
khosman’s picture

I'm not sure why I can't configure this - but thanks loads for the help.

While I still can't seem to create a simple restricted dropdown, the immediate fix I've implemented is to use the "Relevant Content" module. It's bugging me that I can't solve the issue from an academic standpoint, but Rel Content gives me (in the end) what I'm looking for. (And, wow, what a great time saver. I'm lovin' it.)