Jump to content

How to do filtering with page references without URL segments?


Recommended Posts

Posted

Hei,

I'm trying to create a simple filter for my blog posts, but have not had luck yet. The posts use a page reference field value as their category. However, different from the examples I found in the forum and below, I don't have the categories as part of my URL, and because of that, I can't use the url segments. On the front end, I also have pagination, which makes things a bit more complex for me.

Here is my setup: I have two templates. One is blog-index.php and blog.php.


2024-02-19_10-16.thumb.png.8ae4be0b44267801b6eced512a96c9ac.png

And inside the blog post:

2024-02-19_10-16_1.png.3fb666b3ba21bacaeb84cf26a44cfedd.png

Posted

@Boost could you elaborate more on what you mean by filter.
If you want a url like domain.com/blog/category_a/  to show all blog children pages with a page reference field value of category_a, then url segments are perfect for this.

URL segments are a good tool if you cant use your page tree structure

Posted

Hei @ngrmm. I have a blog index page like below. As you see, I have each post tagged with a category. However, my posts URL do not contain the category, so they are like https//acme.com//blog/what-is-conversational-ai/. I want to have a simple select dropdown with my categories: All, Technology, Insights, Customer Experience..etc. So, when you select, for example "Insights", only posts from that category would appear. 

2024-02-19_12-45.thumb.png.306dfa1903e67b1b96cc566002868ede.png

Posted

ok. got it
ProcessWire let's you do whatever you want on frontend. So you have to come up with you preferred solution. There are many solution for your goal. Two of them would be to
A: do the filtering with javascript (custom js or scripts like mixitup.js)
B: or using processwire url segments and a link list (your dropdown) to those url segments
 

Posted

The frontend is not the issue, since I can even use UIKIT. My issue is the pagination. The frontend solutions would just "filter" the results on the current page. But if I have a select element on the blog index and select "technology" category, the pagination should reflect that too.

Posted

With a js frontend solution your php code would output all posts and you would have a js pagination.

Just try the url segment way. If everything is working, you make it ajax driven 

Another similar option would be HTMX

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...