Jump to content

[solved] Issue using Toggle Fieldtype in selector for pagination


ottogal
 Share

Recommended Posts

Hello all,

using PW 3.0.148 with the regular site profile for a blog, I got an an empty pagination output when I had a Toggle field in the selector.

The Toggle Fieldtype was introduced with https://processwire.com/blog/posts/pw-3.0.139/ .

The selector resulting in empty pagination:

$posts = $pages->find("parent=blog, sort=-date, limit=10, toggle_field=0");

It worked well, when I replaced the Toggle field with a Checkbox field:

$posts = $pages->find("parent=blog, sort=-date, limit=10, checkbox_field=0");

So the prerequisites for the pagination to work are given.

The settings for the Toggle field were:

  • Formatted value: Integer
  • Label Type: Yes/No
  • Input Type: Toggle buttons
  • Default selected option: No

Thanks for any hints!

Link to comment
Share on other sites

Check if the selector returns any results (echo $posts->count;).

Looking here, it seems like you've set your field and selector right, but just maybe you have changed default state for the Toggle Inputfield after it has been created for your posts and it still holds the '' (empty string) value for the most of them if not all. You can look in the database to be sure.

  • Like 2
Link to comment
Share on other sites

18 hours ago, Ivan Gretsky said:

changed default state for the Toggle Inputfield after it has been created for your posts and it still holds the '' (empty string) value

Indeed, that was the reason for the strange behaviour.
Thank you, Ivan, for your help.

  • Like 1
Link to comment
Share on other sites

Sorry, but i have to pour some water into the wine: It works well only on my local installation (xampp), but not on the live site.

With   toggle_field=1  in the selector, the output is correct;

with   toggle_field=0   the output is empty, $posts->count() is 0.

Considering a remark in https://processwire.com/blog/posts/pw-3.0.139/ I thought it could be necessary to make it a required field. But that changed nothing.

Finally I got it to run correctly by editing the value in each single post (changing it to 1, save, changing back to 0 and save again) - at least there are not so many posts at the moment...

Obviously setting the default value to 0 (directly at the creation of the field) has no effect at all.

Just an hour ago I realized that the very same issue was adressed by @Nils Wiere in this post (and that I already asked back in June...):

  So further help is much appreciated!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...