Portfolio and Pagination
Hello I have developed a Portfolio, the pagination is done using the method given and I have limited a page to display xx number of items before paginating. So far so good.
Now my Portfolio uses a JQuery plugin to show and hide listings based on filters as I gave up trying to get the category filter to work driven by Perch.
Problem is that if you filter items, if some naturally fall say on page 2 of the "All" results, then thats where they stay when the filter is applied. So say in a grid of 9 items, even if there are only 5 items, 3 might fall on page 1 and 2 on page 2. Not ideal.
Is there something I could add to the pagination code to stop this? Or maybe turn off pagination when using the filters?
See the section here: https://dev.marketingalchemy.co.uk/portfolio/
Or is there a way to do this in Perch that will work?
Your jQuery code is filtering from the content on the page. To filter the full set of content, you need to start with it all on the page.
Yes thanks I suspected that was why, but that would make the "All" page potentially very long.
Is there a way to achieve this using Perch categories? Or a way to feed all the items to those filters without displaying them all?
If you want the jQuery filtering, the best route is to write your pagination with jQuery too.
I am not so bothered about the filtering being jQuery, its just I could not get the Perch Category to work.
Could I achieve something similar within Perch? I already have the categories set up.
Yes, you can do that with categories.
So let me just clarify something, if done with Perch when you click on a filter link, would that have to go to a category page or would it just display within the same page?
As you know I struggled to get things to work before.
You could set it up either way.
Unfortunately, I deal with so many people asking questions here every day that I can't keep track of who has done what before.
So I have this in my portfolio listing page:
What do I need to do to filter by category inside this page and what do the links need to end up looking like to filter by these? I studied the solution and its geared towards using a category page. Stuck!
If your category set was 'portfolio' and you had a category of 'brochures', for example, you'd filter them like this:
Thanks for tip, how would I code this so it changes on click of a link? And will this load inside the existing page without refreshing the whole page or is that not possible?
That would be achieved using JavaScript which really is outside the scope of the support here. I'd suggest asking on a forum that is focused on front-end development.
Okay I understand, what I want to ask is in your video it sounds like you can select the category via a link. But the above code is to hard code the category.
Do I need to make a page with above for each category e.g. brochures.php or is there a way to auto create this?
If you are back to wanting to filter from within Perch, rather than with JavaScript, then just pass into the array the category slug from the querystring instead of hardcoding it.
Where do I find the method to do this please, as the one on the Portfolio with Categories solution is fed from a separate page?
perch_get('s')
will be the value on the QueryString (assuming the parameter iss
), just as in the example.You can't do it without reloading the page unless you do the filtering in JavaScript as Drew explained earlier in the thread.
Not sure what I have done wrong, I have this in portfolio.php
and in the category template:
If I use this url as example: https://dev.marketingalchemy.co.uk/portfolio/?cat=brochures
It does not display an items.
If I hard code a category portfolio/brochures into list page it works.
What have I done wrong?
Have you enabled debug to check? https://solutions.grabaperch.com/development/how-do-i-debug-problems
Cannot see any errors.
Can you confirm if the slug for the catSlug should be present and in which template, its inside the category_single template I am using to create Categories but confused as to whether its needed elsewhere?
You need use a category path like my example. The category slug alone is not enough, because that category could appear in multiple sets.
Just to check then if I type this as a url: https://dev.marketingalchemy.co.uk/portfolio/?cat=portfolio/brochures
Then it displays the brochures category, so how could I get it to work without the portfolio in ?cat=portfolio/brochures