0

What I am trying to do is create a content type with a taxonomy vocabulary field. When creating the content type and selecting one or more of the terms, I would like the content type with an attached view to render the node with a list of nodes (ex: teaser views) that share share the content type's selected taxonomy terms.

In the past I have used Insert Views and listed the taxonomy terms. I would like a more elegant solution so a user can just use a selection list or term radio buttons.

How would I go about attaching a view and passing the taxonomy terms of the content type to the "attached" view?

Thoughts?

Thanks.

Rich

  • So you mean when creating the node, when you select any taxonomy term, all the nodes with the same taxonomy term should be displayed ? – mohit_rocks Apr 12 '13 at 5:10
0

You can pass to the template, a variable which contains the second view value

function mymodule_entity_view($entity, $type, $view_mode, $langcode) {

  list($id, $rev, $bundle) = entity_extract_ids($type, $entity);
  switch ($bundle){
    case 'customtype':
      if( $view_mode == 'teaser' ){
        $entity->test['test'] = array(
          '#markup' => views_embed_view( 'view_2', 'default', $entity->field_custom['und'][0]['value'] ),
        );
      }
    break;
  }
}

Then, in your theme, a node--customtype.tpl.php, you can render the variable:

print render($test);

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.