Boost Posted February 19 Share Posted February 19 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. And inside the blog post: Link to comment Share on other sites More sharing options...
ngrmm Posted February 19 Share Posted February 19 @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 Link to comment Share on other sites More sharing options...
Boost Posted February 19 Author Share Posted February 19 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. Link to comment Share on other sites More sharing options...
ngrmm Posted February 19 Share Posted February 19 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 Link to comment Share on other sites More sharing options...
Boost Posted February 19 Author Share Posted February 19 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. Link to comment Share on other sites More sharing options...
ngrmm Posted February 19 Share Posted February 19 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now