Skip Navigation

[Resolved] One View for Various Pages

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 55 replies, has 2 voices.

Last updated by Pete 4 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1683301

Hi there,

Asking a question and have given it some thought, can't see if it would work...worth an ask.

Say...we have one View that has a filter with various Areas,
The default is, all Areas are shown until you select other wise...like on this page: hidden link

Click the third filter Area, there are a few areas to select.

Using this View, I would like to create various pages for each Area in the drop down.

Rather than create several separate Views, with each filter pre set in Query Filter, is there a way of using one view and setting 'somehow' the Area to be pre selected for each page.

Hope that makes sense 🙂

Thank you in advance for any thoughts.

#1683633

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As I understand - you want to create a single view and you want to use that same view to filter by specific area.

For example:

[wpv-view name="view-name" passedarea="devon"]

[wpv-view name="view-name" passedarea="wales"]

If above is true - you should create your view in classic mode (as using blocks filter by shortcode attribute is not supported as the moment).

Add a "Query filter" from the "Query Filter" section for your area custom filed and and set it to filter by shortcode attribute and the value should be "passedarea".

Then, you should add your view as shown above.

[wpv-view name="your-view-slug" passedarea="devon"]

Where:
- Adjust the your-view-slug and passedarea values as required.

More info:
=> https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes
=> https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/

#1683861
Tax filter.png
added shortcode.png

Hi there Minesh,

Thanks for getting back to me.

OK, I have tried to follow your instructions.

I have added in Tax Filter as you suggested? Not sure this is right.

I have then added shortcode as suggested, however this isn't working right on front end.

Also, we have filter and results in different columns, is this still possible using short codes?

This the page we are testing: hidden link

Many thanks. Pete

#1683971

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I would like to know why you are using the filter and results now.

It seems we have misunderstanding with your requirement.

Using the following method:
- The following view will display posts belongs to term: devon

[wpv-view name="view-name" passedarea="devon"]

- The following view will display posts belongs to term: wales
[wpv-view name="view-name" passedarea="wales"]

Both above view should be added independently on the page (not within another view).

Is this not your requirement that you want to display your posts per term? If no: Please share more details with your requirement with test case example.

#1683977

Ok, I'll try and explain what I have seen on other sites like ours.

See this page as it is now: hidden link

The location filter (on the left) is set to Norfolk, this on a Norfolk page.

We would like exactly this, for many pages in different areas.

So on another page, say Suffolk...the exact same filter would be set to Suffolk and all properties shown.

If the visitor wished to change the set filter to another area, they could...the aim is to have the filter set for individual pages.

Is this possible?

I can create many Views to do this however was hoping not to.

#1684035

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I got it now. I need bit more information.

I would like to know how the location field is setup? is it setup as custom field or taxonomy?

And if its set as custom field or taxonomy - is the location field is setup per location? How we can not that on the following page we need to display only options belongs to norfolk with location dropdown?:
=> hidden link

#1684045
see here 45.png

Cool, it was hard to explain in a typed message 🙂

Both are set up as a Taxonomy. Area is one, Location is another. They work independently of each other.

The Area is also set for every listing, the Location for certain featured listings.

#1684973

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The thing is that there is no way to add taxonomy filter based on the specific pages as by default taxonomy filter options are displayed based on the terms that is assigned to the currently displayed result set.

I still wonder how we can identify that if the page X is displayed then taxonomy filter Location should be displayed with set of options like(one,two,thee) and if the page Y is displayed then taxonomy filter Location should be displayed with set of options like (five, six, seven) where options are just shared here as example.

#1685081

Hey Minesh,

I did think it was a challenge and couldn't see how this would work.

For a further example, this site does what we would like...each page is set to a Destination..

hidden link
hidden link

Of course each has it's own URL, they have a large number of pages that are like this.

So I guess, if there is no way of achieving this with one View...

Can I ask:

1- I can create a View for each, this will add about another 30 Views to the 20 we already have. Will adding so many Views to one site cause performance or speed issues?

2 - For each of these Views, I would like to use the same Location filter which has 'all locations'. Is there a way in Query Filter I can include all locations yet pick one to appear as default (first)? Then set a different one to appear first for every View I need to create.

Many thanks, Pete

#1685133

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I think I got the workaround.

Lets say you are on the following page:
=> hidden link
- So what you need to do is, you need to edit your default post type "page" from Toolset => Post Types => Edit "Page" post type and assign the "location" and "area" taxonomy to your page post type and save your "page" post type.

Then, edit the following page:
=> hidden link
- And assign the terms using "location" and "area" taxonomy which falls into norfolk.

And then, we can create a view and add a query filter to filter type view by taxonomy location using a page where this View is shown.

Does this sounds good? all you need to do is assign the taxonomy to your page post type and later edit your page and add the terms where page belongs to. You can run a test on test install and let me know if that helps? Maybe as you need to use custom search with "location" taxonomy as "location" taxonomy is added as filter, we need to use view's filter hook "wpv_filter_query"

If the above workaround could help - you can share a test site where I can setup a demo for you.

#1685183

Hi there,

Hmmm you've lost me a bit. I understand what you mean re default post type "page" from Toolset => Post Types => Edit "Page"

However you've lost me there with the rest. I could send you login details if you private the message.

The site is live however the page and View in question isn't.

Thank you.

#1685403

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

We do not recommend to play with live site.

And I do not understand when you say "However you've lost me there with the rest". What you mean exactly.

Would you mind to share test site or I should setup for you and show you the demo but I would recommend that if you can share a test site which is 1:1 copy of your live site where I can play around and make changes.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1686035

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing the test site.

So, what was I saying, as you can see with the following link:
=> hidden link
- I've set the "Location" and "Area" taxonomy to display with the page post type.

Now, when I edit the specific page, in this case "Norfolk Holidays" as given under:
=> hidden link
- You will see that taxonomy "Location" and "Area" are available on right panel from where you can set this page belongs to what area and what taxonomy.

Now, we can create a new view or use the existing view and change the query filter for taxonomy "Area" and "Location" and set the taxonomy filter option to "Set by the page where this View is shown".

This way we can identify that this page has to filter by this terms. Does this sounds good?

#1686091

Morning, or afternoon where you are.

Yes the test site is prob best for this. I just hope I can replicate what you've done on the live site 🙂

I can see what you've done and sounds perfect.

So the end result will be a one View thats output will change, per page depending on what is selected in Area and Location?
If that's the case....you're a genius 🙂

#1686245

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So the end result will be a one View thats output will change, per page depending on what is selected in Area and Location?
==>
Yes - the end result will be a one view that will output the related posts belongs to terms selected from taxonomy "Area" and "Location" from the current page which you are displaying.

Would you mind to setup couple of pages with your desired "Area" And "Location" and send me the links of those couple of pages as
well as tell me what view I should use with those pages.

Can I use the following view with the example pages you shared?
=> hidden link