Hello People! First of all thanks for an excellent module cck + nodereference. However I need a little more functionality, just a minor one. Here is what I need:

  1. First there are two content types content types I'm concerned with, one is the Event (provided by the event.module) the other is Venue( created using cck). The Event content type has been extended to refer to the Venue type using the nodereference.module in cck. The purpose for this it to provide the Venues where the Events are held.
  2. Then comes the problem of making views that filter content based on the properties of the referenced type, in my case the Venue. The nodereference.module provides only the name of the Venue as a filter for creating custom views.
  3. What I need to do is add some of the attributes of the Venue type, for example its locative information and it's category types(list of taxonomy terms) as filter options for the views module using the noderefernce.module not the content type itself.

So the filter option should show in the drop down list entitled "Add Filter:" in the add view page as "Node Reference: Venue Location" or "Node Reference: Taxonomy terms of Venue type" but not like this "Location: City" or "Taxonomy: Terms of Venue type" (these are there by default anyways, there is also "Node Reference: Venue" which gives only the list of titles of all created Venues but what I want is the list of taxonomy terms of the Venue content type and the list of the Location information). So how do I do this? I believe I have to edit the code for nodereference.module and I know where I need to modify it but how? It would be really helpful if someone showed me how to expose content attribute as filter for the views.module in general.

CommentFileSizeAuthor
#5 cck_filters.jpg65.31 KBtsega

Comments

moshe weitzman’s picture

This capability a promised feature of Views2. It will then be up to CCK/node_ref to make use of it. Your solution is not coming for quite some time. At the highest level, you need to use hook_views_tables_alter (i might have that name off a bit) to add some new tables and a new filter in that table. your custom table will define the join needed for your query. sorry, this is complicated stuff. i haven't even done it yet, i just have an idea about process.

tsega’s picture

Thanks moshe, me and my friends are working on it and I will post something if we can come up with a good solution. It's good to know that Views 2 will have this feature and I'm looking forward to it. Thanks Again. I will post back asap.

tsega’s picture

The link below is a great help but I need to know if someone out there is able to add the non-standard node field types for the referenced node as well.
http://drupal.org/node/70380

jbalean’s picture

Hi Tsega,

I've been having the same problem, where the client would like to filter an event view by a region category. I also stumbled across the http://drupal.org/node/70380, and have been modifying that. Looking at /modules/views/modules/views_taxonomy.inc gave some clues, which lead me to the following

function nodereference_views_tables() {
  ...
  foreach (content_fields() as $field) {
     ...
  }

  // Add vocabulary filters
  $vocabularies = taxonomy_get_vocabularies();
  foreach ($vocabularies as $voc) {
    $tables['term_node_'.$voc->vid.'_node'] = array(
      'name' => 'node',
      'provider' => 'internal',
      'join' => array(
        'left' => array(
          'table' => 'node',
          'field' => 'nid'
        ),
        'right' => array(
          'field' => 'nid'
        )
      ),
      'filters' => array (
        'tid' => array(
          'name' => t('@name Referenced Node: Taxonomy: Terms for @voc-name', array('@name' => $name, '@voc-name' => $voc->name)),
          'value' => views_taxonomy_form($voc),
          //views does handle this as array regardless what we state here due to the operators
          'value-type' => 'array', 
          'tags' => $voc->tags,
          'operator' => 'views_handler_operator_andor',
          'handler' => 'views_handler_filter_tid_custom',
          'option' => 'string',
          'vocabulary' => $voc->vid,
          'help' => t("Only terms associated with %voc-name will appear in the select box for this filter. When filtering by taxonomy term you may specify the 'depth' as an option. Please see the taxonomy help for more information.", array('%voc-name' => $voc->name)),
        ),
      ),
    );
  }
}

Hopefully this is on the right track. I could not get any events displayed when I selected some terms with 'Is one of', however it definitely showed them when I selected some terms and then 'Is none of'. Possibly I have my category incorrectly set up (new to Druple) and so I decided to post anyway. Let me know if it works for you or you make any progress.

Regards,
James Balean

tsega’s picture

Title: How to provide more fields of the referenced type as filters for the Views Module. » How does CCK provide the default filters for the views module?
StatusFileSize
new65.31 KB

Thanks jbalean me and my friends are trying it out but I need another help form you or from anybody who can help. I need to know how CCK provides the default filters for the views module. Meaning when ever we create a content type with CCK fields, CCK automatically provides these fields as filters for the views module. How does it do that, where can I find the code? I have attached a picture showing these fields please check it out to clarify what I mean.

Dzsozef49’s picture

karens’s picture

Status: Active » Closed (won't fix)

Closing old issues. None of us is using the D5 version any more, so hard to provide any support. Sorry.