Jump to content

wesp
 Share

Recommended Posts

Hello everyone,

I am struggling a little bit with combining Isotope with Processswire.
The functions themselves work nicely and I managed to give the sortable items their categories via a page field and now I also want to make the sort order manageable with a field instead of on the actual site, so the client can easily set the way they want their stuff ordered.
I am using a Select Options Field and am giving the sortable elements an extra class with that, and that does actually work, looking like this:

<h2 class="headline_article<?php if ($home->sortPreviews->value == "headline"){echo " is-checked";}?>"><?php echo $article->headline; ?></h2>

The only problem I have is that for the headline I want the sort order to be ascending, but for the date I want it to be descending, and as far as I know with my 1 month of coding knowledge I can only set it as either or in the grid defining javascript.
Which now basically looks like this:

var $grid = $('.grid').isotope({
  getSortData: {
	selectedCategory: '.is-checked',
  }
});

$grid.isotope({
	sortBy: 'selectedCategory',
	sortAscending: {
		selectedCategory: false,
	}
});

is it possible to either check if the item that now has the class "is-checked" also has the class "date" and then to set the sort order to descending in that case while in any other it should be ascending?
Or if not is there maybe a different way to approach the whole idea?

Any help is much appreciated!

Link to comment
Share on other sites

Ok I found this codepen: multiple sortBy and through rearranging and cleaning up my code a bit, as well as making the sort order static and not changeable via a page field this

sortBy: ['featured', 'date'],

actually works, where the items get first sorted by the value of featured and if that is the same they get sorted by date.

  • Like 1
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...