How To Create Views within Views ?

  0 comments
Share

Hi guys, Today i am going to show, how to show views within views. So before started it, i wanna say what's the need of it. Actually i was developing a website and i had to show all the store of that company city wise. So i did it with this way. Here i am share how i did it.

Step 1:

Download Views.

Download Views Field View.

Enable both module.

Step 2:

Go to admin/structure/taxonomy/add and create Vocabulary with name City.

Views Image

Then add term for it.

views views Img2

views viewsImg3

Now create a content type called Show Store with term reference field

views viewsImg4

Create some content through this content type

Step 3:

Go to admin/structure/views/add and create a view with name cities listing for Inner Views

Click on add button of Contextual filters

views viewsImg5

Check Content: Has taxonomy term ID box

Click on Apply (this display) button

Check Display contents of "No results found". box

views viewsImg6

Check Specify validation criteria box

Choose Basic validation and Display contents of "No results found".

views viewsImg7

Save the configuration

When you have done this, your View preview will show as empty. But don't worry about it.

Step 4:

Again Go to admin/structure/views/add and create a view with name City Store for Main Views

Select Taxonomy Term from Show and City from Type, and click on Continue & edit button.

views viewsImg8

Scroll down and you would find your terms

views viewsImg9

Now we need to connet Inner Views which we have created in Step 3.

As we have created Contextual Relationship called "Content: Has taxonomy term ID". So we have to add a "Taxonomy term: Term ID" field, so that the contextual relationship can hook onto it.

Click on Add button under Field

Choose "Taxonomy term: Term ID".

Check the Exclude from display box.

Click on Apply (all display) button.

After Saving the configuration, it will create connection.

Now we need to call Inner Views within this Main Views.

Click on Add button under Field

Choose Global: View.

views viewsImg10

Under View Setting select Inner Views which you have made in Step 3. In my case i created Cities Listing

views viewsImg11

Scroll down and Click Replacement Pattern

Copy the token from Taxonomy term: Term ID.

Scroll up and find Contextual filters, paste Taxonomy term: Term ID token here

views viewsImg12

 

Now all done save the Views.

views viewsImg13

Add new comment