Skip Navigation

[Resolved] Distance from filter based on parent post address field – part II

This support ticket is created 4 years, 8 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Author
Posts
#1583103

I really don't understand the logic of the process, I thought there should be one view for creating the comma delimited list of parents and one for showing the children of that list but it looks like I need to keep all 4 views (2 originals + 2 duplication) ?
You must keep 3 of the Views. I asked you to make a duplicate of the original Distanza Negozio View so you would have a backup in case you needed to start over, but it is unnecessary. The original Distanza Negozio View is the only one you don't need right now. The other 3 Views are necessary:
- find parent posts
- produce comma separated list of related child post IDs from those parent posts
- display sorted, formatted child posts list using those IDs

I did all of the above, but I see no results, the page is blank.
I am not sure which page you are referring to, so I'm working here:
hidden link

The results are here:
hidden link

This is the code I added:

Distanza-negozio-2 for debugging: {!{wpv-geolocation}!}{!{wpv-view name="distanza-negozio-2"}!}{!{/wpv-geolocation}!}

Distanza-negozio-children-2:{!{wpv-geolocation}!}{!{wpv-view name='distanza-negozio-children-2' ids='{!{wpv-view name="distanza-negozio-2"}!}'}!}{!{/wpv-geolocation}!}

I also added some code to fix the JavaScript error regarding the Print button we already discussed:

<span class="btn-print" style="display: none;">I added this btn-print to fix the JavaScript error</span>

After that, I cleaned up the two Views that are used to produce comma-separated lists. I deleted all the extra spaces from these Views:
hidden link
hidden link

Please take a look and let me know your thoughts.

#1583905

Hi Christian,
now I see the logic, thanks. It works fine although it means that every time I want to create a page I need to use this structure and this makes it all more complex. For example I just read that distance filter can't be used for archives, so I have to replicate archive pages with views. This is ok, but how can I pass the category to this structure ? at what level ? with a simple page it would be easy .... also, I have a custom search page (see RICERCA page) and I need to add distance filter here: how to ? ... Honestly I could never be able to find this solution without your help, I am just worried that going on I won't be able to add new pages without your assistance.

One question: in Distanza-negozio-2 when no products are found the comma is added anyways so you get ,,,,,: is that an issue ? or better add a conditional filter to add comma only for found items ?
thanks
Regards
Nicola

#1584327

This is ok, but how can I pass the category to this structure ?
I didn't realize that was a requirement so it wasn't set up to support that. I have added some shortcode attributes for you to facilitate this. You'll use a shortcode attribute wpvcategoria on the distanza-negozio-2 View to pass a category term slug into this structure. In this case, I have passed in casa_giardino as the term slug:

:{!{wpv-geolocation}!}{!{wpv-view name='distanza-negozio-children-2' ids='{!{wpv-view name="distanza-negozio-2" wpvcategoria="casa_giardino"}!}'}!}{!{/wpv-geolocation}!}

One question: in Distanza-negozio-2 when no products are found the comma is added anyways so you get ,,,,,: is that an issue ? or better add a conditional filter to add comma only for found items ?
The commas here aren't important and do not contribute to the post ID filter. I wouldn't worry about conditionals for them, it's not worth the time you'll spend on it.

#1585007
rel.png

Hi Christian,
So it looks like it's possible to pass the category to the first level down to the second and third. This is great. This solution also allows me to use the Many-to-Many Store-Offer relationship (same offer sold by many stores). This is great too, although I noticed that the distance displayed is the one of the first relationship regardless if the closest store is another one in the relationship, .... see picture. Of course this makes no sense to the user. Is there a way to sort or remove relationships by distance in order to show the distance of the closest one ?
Thanks
Regards
Nicola

#1585715

I'm looking here, for your reference:
hidden link

The distance and featured image shown in the table are determined by this code:

<td style="padding:3px;vertical-align:middle;"><div style="width:35px;height:35px;">[wpv-post-featured-image item="@negozio-offerta.parent"] </div></td> 
<td style="padding:3px;vertical-align:middle;">[toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-negozio_indirizzo_completo' postmeta_id='[wpv-post-id item="@negozio-offerta.parent"]']km</td> 

Since it's a many-to-many relationship, there can be more than one negozio-offerta.parent. The only way to determine which parent to display is to use a view. I have replaced this code with a View of the related negozio posts, ordered by distance to the User (ascending), and limited to 1 result. I moved the original code into the loop of this new View.

[wpv-view name="distanza-negozio-parent"]
<td style="padding:0px;vertical-align:middle;padding-left:3px;">[wpv-post-link]</td>
<td style="padding:0px;vertical-align:middle;text-align:right;padding-right:3px">-[types field='offerta_sconto'][/types] %</td>
#1589079

Hi Christian,
thanks 1000 for this, it worked perfectly, I was even able to replicate the structure for a different page. I will work on another one that adds a custom search, see what happens 😉 . Just a little question more: is thare a way to pass the category from distanza-negozio-children to distanza-negozio-children-2 ? I need to create a link to be shown only if anything found.
Thanks
Regards
Nicola

#1589567

Hi Christian,
I just realized that there is another issue related to archives.
How can I replace the [wpv-post-taxonomy type="categoria"] function ? I mean, after having used this views system to limit the selection of products offered in stores within the defined distance I expose the list of those products. This works but in the details of each single product I expose [wpv-post-taxonomy type="categoria"] allowing the user to select any sub-category that product belongs to, but the links automatically created by [wpv-post-taxonomy type="categoria"] is an archive page so the distance limitation goes lost! So I think I should replace [wpv-post-taxonomy type="categoria"] with a view listing all category levels for the current product ID in the loop and create links to pass the category to the same views system. To do this I have created a new view called Pseudocategorie but I cannot figure out if I have to loop over offers and get categories or loop over categories ... I tried both but got no results...
Please help, thanks

As I said I have recereated a similar system for replacing archives, views are called Pseudoarchives Lvlxxxxxx linked to the "Vedi Tutti" (see all) links under each table in homepage, for example see hidden link

thanks
Nicola
PS a similar view will be needed to replace [wpv-post-taxonomy type="post_tag"]

#1593285

Just a little question more: is thare a way to pass the category from distanza-negozio-children to distanza-negozio-children-2 ? I need to create a link to be shown only if anything found.
If you want to access the category in the distanza-negozio-children-2 View, the easiest way is to add it using a shortcode attribute on the distanza-negozio-children-2 View. You can do something like this:

{!{wpv-geolocation}!}{!{wpv-view name='distanza-negozio-children-2' othercategoria='casa_giardino' ids='{!{wpv-view name="distanza-negozio-2" wpvcategoria="casa_giardino"}!}'}!}{!{/wpv-geolocation}!}

Then inside the distanza-negozio-children-2 View, you can access that othercategoria shortcode attribute using the wpv-attribute shortcode:

[wpv-attribute name='othercategoria']

That would print casa_giardino in this case.

How can I replace the [wpv-post-taxonomy type="categoria"] function ?
You want to replace this shortcode inside the Single Product template, is that correct? You should create a View of this taxonomy, and filter it by taxonomy term, set by the page where this View is inserted. In the Loop Editor, for now, just output the taxonomy term title. This should help confirm the Query Filter is at least working correctly to determine which terms should be included here. Place that taxonomy View in the Single Product template and tell me the results.

#1596795

Hi Christian,
Passing the category: solved thanks !
View to show taxonomies: Done that, it's called Pseudo-post-taxonomy and if added to single post it works (see Single offerta template, at the bottom), but if added to PseudoArchives it doesn't (PseudoArchives is the same set of views I recreated to replace archives due to the "distance not working in archives" limitation). It should work in both ... why it doesn't ?
I also tried to show [wpv-taxonomy-link] instead of [wpv-taxonomy-title] but, again, clicking on a category the distance limit goes lost .... how can I recreate the link maintaining the distance ? what about passing the taxonomy as argument to the PseudoArchive set ?
Thanks
Regards
Nicola

#1597873

It should work in both ... why it doesn't ?
My guess is that the Query Filter is configured as "Filter by term set by the page where this View is shown". That works well on the single post, because the taxonomy terms are applied to the single post. The filter knows which terms should be displayed in the View because they are the same terms applied to the single post. When you place the View somewhere else like a custom Page, the Query Filter doesn't know which terms to use in the filter because the taxonomy terms are not applied to the custom Page where the View is shown. You would have to choose a different filter setting to respond to a shortcode attribute or a URL parameters.

how can I recreate the link maintaining the distance ? what about passing the taxonomy as argument to the PseudoArchive set ?
Yes it sounds like you need a way to pass the taxonomy as a URL parameter or shortcode attribute somehow. In your taxonomy View you will create links with HTML, and add the required URL parameters as needed. For example:

<a href="<em><u>hidden link</u></em>">[wpv-taxonomy-title]</a>

Then in the pseudo archives page, you can use the wpv-search-term shortcode to get those URL param values and pass them into the View using nested shortcodes. For example, if your View requires a shortcode attribute of terms, and you want to pass the value of the otherparam URL parameter into that shortcode attribute:

[wpv-view name="Your view" terms="[wpv-search-term param='otherparam']"]

Does this make sense?

#1599839
Senza nome.png

Hi Christian,
Filter: I changed it into "current post" and it worked for both, great !
Pass the taxonomy: done! I created the param and passed it to the view with terms=, changing the filter to get the param. Great !
I also created a view (PseudArchive Title) to get the taxonomy desc of the passed param for the page title. It should be very simple but it fails the category, it shows another one, could you please check it ?
Then I replicated the pseudocategory view to pseudotags view, but this one returns no tags, only commas are shown, see picture ... I don't understand why, it's just a different taxonomy ....
Also I have noticed what it's shown in the picture: categories are sorted by Term group and this works for all posts but those indicated (Robot) I checked that Robot is actually a subcategory of Elettrodomestici (domestic appliances) and it is, is it a sort bug or what ?
Thanks
Regards

#1602839

I'll be glad to take a look, but it looks like Views has been disabled. Are you working on something at the moment? I'll check in later.

#1603271

Hi
no.... everything works fine as usual, Views is activated ....pls let me know if you have issues loggin in, I might have changed the pwd by mistake, in case open a new private session I'll give you a new one.
thanks
Nicola

#1604797

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Nicola,

Christian is currently unavailable today but he will be back tomorrow to continue assisting with this.

Thanks,
Shane

#1610285

Hello Shane/Christian
any news on this ?
Thanks
Regards
Nicola