0

Hello I need to create a block that when is on the article page to show all the related content from the edition it belongs.

I tried with views but the problems comes from the fact I cannot add a filter of the current edition.

I think this should be done within a module but I needs some clues. Thanks.

  • 1
    What does you mean by "edition"? – kalabro Nov 17 '11 at 12:36
1

I presume you categorize your content using taxonomy terms, or? So, as an example, you create an article for issue number '122' and you 'could' use this in the url of your article, such as www.example.com/articles/issue_number/node_id

In this example, if the node id was 12345, the full url would look like this:

www.example.com/articles/122/12345

Now you could use views and arguments - in Views 3 'Arguments' was renamed to 'Contextual filters'. So,

  1. Create a view -> create block -> unformatted list -> titles (linked)
  2. add a Contextual filter
  3. Content -> Has taxonomy term ID
  4. When the filter value is NOT in the URL: -> Provide default value ->
  5. Type: Taxonomy Term ID from URL -> Load default filter from node page, that's good for related taxonomy blocks.
  6. Check the boxes of the taxonomies you want involved here
  7. skip to point 11

------------ old way -------

  1. Provide default argument -> php code

    $node = node_load(arg(1));
    if($node) {
    //Be sure to rename ->field_taxonomy_name to your field name
    foreach($node->field_taxonomy_name[LANGUAGE_NONE] as $term) { $terms[] = $term['tid']; }
     return implode('+',$terms);
    } else { return; }
    
  2. Allow multiple terms per argument -> yes

  3. Reduce duplicates -> yes

^^----------- old way ---------^^

  1. Create a second argument to remove the currently displayed node from related content block
  2. so, add a 2nd Contextual filter
  3. Select Node: Nid
  4. Action to take if argument is not present -> Provide default argument
  5. Default argument type -> Node ID from URL
  6. Exclude the argument -> yes
  7. Save
  8. Add block to node pages, only display in articles/*
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.