Skip Navigation

[Resolved] View returns zero results after adding sorting control

This support ticket is created 5 years 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 8 replies, has 3 voices.

Last updated by ericE-4 5 years ago.

Assisted by: Minesh.

Author
Posts
#1422363
Screenshot 2019-12-23 14.38.23.png

I have a View that has been used on a page to display data from a repeatable field group for a while. Today, I added a sorting control to the Search and Pagination section of the view, so that users could control the order of the output. As soon as I did that, the View stopped showing any results, no only outputting "No items found: outer View"

I can't figure out why this is happening nor how to fix it. Can you help?

This is my Search and Pagination code:

[wpv-filter-start hide="false"]
[wpv-filter-controls]
	[wpv-sort-orderby type="select" options="field-wpcf-nights,field-wpcf-fishing-days,field-wpcf-price" label_for_field-wpcf-nights="# nights" label_for_field-wpcf-fishing-days="# fishing days" label_for_field-wpcf-price="Price" orderby_as_numeric_for="field-wpcf-nights,field-wpcf-fishing-days,field-wpcf-price" orderby_ascending_for="field-wpcf-nights,field-wpcf-fishing-days,field-wpcf-price"]
[/wpv-filter-controls]
[wpv-filter-end]

The loop editor:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<div class="packages_wrapper">
		<wpv-loop>
			[wpv-view name="package-row"]
        </wpv-loop>
	</div>
    <!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found: outer View[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

The Query section is shown in the attached image.

The View is called "Pricing packages list". An example page where it can be seen is hidden link

#1423111

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

The reason why views was not able to display the repeating field group entry because with the following view you set the ordering setting to a custom field "Nights" and the field "Nights" is actually not the part of the repeating field group "Package" that is why view query get failed.

As you can see now with the following view - I've set the ordering setting to 'Post ID' and Now at least its showing the results :
=> hidden link

The view where I changed the ordering section is as given under:
=> hidden link
Screenshot:
=> hidden link

I see also many notices from the plugin "my-custom-functions".

Do you mean that you want to still add sort by options that you added to the "Search and Pagination" section? If yes, please note that you can add the sorting fields for the fields that belong to the content type to which you set your view to the query. Having said that, You are allowed to add sorting fields that belong to the Repeating field group 'Package' in your current case.

More info;
=> https://toolset.com/documentation/user-guides/views/allowing-visitors-to-sort-the-front-end-results/

#1423669

Actually, "Order by" was set to "Field - Nights" for me automatically—I did not manually change that. OI also don't understand why the entire view failed to be produced when set this way. I would expect that if a field was not available to be sorted by, it would just revert to a default sorting method rather than fail to display completely. An error message explaining the issue would help too.

Now that the view is again rendering, I notice that the sorting controls that I added are not displayed. I've followed the documentation at https://toolset.com/documentation/user-guides/views/allowing-visitors-to-sort-the-front-end-results/. How can I allow the user to sort the view results by the fields ""field-wpcf-nights", "field-wpcf-fishing-days", "field-wpcf-price"?

#1424321

Hello,

Minesh is on holiday today. He will be back on tomorrow. He will get in touch with you with the latest updates on this ticket on Friday.

#1425027

OK

#1425633

Minesh
Supporter

Languages: English (English )

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

I would expect that if a field was not available to be sorted by, it would just revert to a default sorting method rather than fail to display completely. An error message explaining the issue would help too.
==>
Thanks for your suggestions. I will discuss this with our team lead.

Now that the view is again rendering,
==>
Ok - great.

I notice that the sorting controls that I added are not displayed. I've followed the documentation at https://toolset.com/documentation/user-guides/views/allowing-visitors-to-sort-the-front-end-results/. How can I allow the user to sort the view results by the fields ""field-wpcf-nights", "field-wpcf-fishing-days", "field-wpcf-price"?
==>
First of all, I see you are using the nested views (view inside another view) - I would like to know what results from you want to sort as you can add query filters or sorting option for the fields that belong to the post type you set your view to query by.

#1426527

I'm trying to provide the ability to sort by fields "Nights", "Fishing Days" and "Price". These fields are all part of the "Package Details" repeatable field group, which belongs to "Lodges" post types. I have used the sorting controls wizard which generated the following code:

	[wpv-sort-orderby type="select" options="field-wpcf-nights,field-wpcf-fishing-days,field-wpcf-price" label_for_field-wpcf-nights="# nights" label_for_field-wpcf-fishing-days="# fishing days" label_for_field-wpcf-price="Price" orderby_as_numeric_for="field-wpcf-nights,field-wpcf-fishing-days,field-wpcf-price" orderby_ascending_for="field-wpcf-nights,field-wpcf-fishing-days,field-wpcf-price"]

Why do the controls not appear?

#1427933

Minesh
Supporter

Languages: English (English )

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

I guess you missed to see the key information I shared in my previous reply.

First of all, I see you are using the nested views (view inside another view)

As the view [wpv-view name="package-row"] is nested inside another view "Pricing packages list" so there is no option to sort the package-row view entries.
=> hidden link

<wpv-loop>
			[wpv-view name="package-row"]
        </wpv-loop>

Another thing is that you set your both the above view to "Disable the wrapping DIV around the View " which means it will display the raw output. So, pagination, ajax that functionality will not work.

And the main reason is that as the sorting fields such as nights, fishing days and price belongs to the RFG "Package Details" and the view that query the RFG "Package Details" is [wpv-view name="package-row"] which is nested in loop, so even if you try to add sorting controls it will display sorting controls n times per loop of view [wpv-view name="package-row"].

So, to add sorting controls to your view is not feasible or possible.

#1428235

.