2

Here is my situation,

  1. I have a view-1 which will list the node titles based on Content: Taxonomy term CONTEXTUAL FILTERS

  2. View-2 which will list all the taxonomy terms (of a vocabulary) with node count.

Now how do I print the view-1 as a custom field within view-2.

The reason I am trying to do this is, I am trying to construct a UI which will display the nodes on click on taxonomy terms with count.

I tried using below code to print view-1 as a custom PHP field on view-2, but it did not work for me.

    print views_embed_view('view-1','block_1', $row->tid);

$row->tid is the term ID argument I am trying to pass

2

The module Views Field View may work for you. It's worth to try.

This module allows you to embed a view as a field in a view. A new field handler is made available, so this can also be used in area (header/footer/empty) handlers as well as rows.

This view handler can accept arguments from fields of the parent view using tokens and pass them into the child view for each row. Raw or rendered token values can be used, as well as static values.

OR

You can even create two displays in a view - one is Page and the other is Attachment.
For your case, view-2 would be Page and view-1 would be Attachment.

You can select various settings in the attachment view such as Attach to, Contextual filter, etc.

enter image description here enter image description here

Check this answer about an attachment view. I had a book Drupal 6 Attachment Views, but could not find a book for D7.

0

I got it working using the below code in 'Global: PHP' > 'Output code' field.

    <?php print views_embed_view('view-1','default', $row->tid); ?>

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.