1

I have two content types.

*content_type1
*content_type2 [set as content profile]        

In content_type1, I have a taxonomy term [user has to choose any one of term] and content_type2 has cck select list field with same terms as content_type2.

I created two roles:

*role1 users can create content_type1             
*role2 users can create content_type2

Now I want to display list of content_type1s in user role2 profile page whose "select field Value" is as same as the "taxonomy term " of content_type1.

How can I implement this using drupal views?

1
  • It seems you need panels rather than Views to acomplish this.
    – Tivie
    Commented Apr 22, 2011 at 8:12

1 Answer 1

1

Seems to me that you're going to need this:

views_embed_view() inside of the user_profile.tpl.php

more specifically:

First set up a view to return content type 1 nodes, that takes an argument of taxonomy term id.

Then, assuming you can get the content type 2 node into user_profile.tpl.php, grab the select list value like so:

<?php
    $selected_value = $content_type2_node->field_selectlistname[0]['value'];
    $term_id = taxonomy_get_term_by_name($selected_value);

?>

note use of taxonomy_get_term_by_name()

and use of a cck select list field named is field_selectlistname, update that to your field name.

then you can use this:

<?php
   print views_embed_view("view_name","block_1",$term_id);
?>

to print out your view.

Note that the first two arguments are the view name of your view, and the display id, which is going to be something like 'block_1', 'default' or 'page_1'

I'm assuming here you know how to set up the view, and know how to get that user_profile.tpl.php to work for your role.. (if isset($account->roles[ role id ])... )

good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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