Jump to content

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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndZyk
      This is a minimalistic website for the german architecture office Weissenrieder Architekten BDA. The front-end uses UIkit 2 and Isotope for the projects overview. Every project category can be accessed in the overview with an URL segment. ProFields Table was used for the project detail view.
      www.architekt-weissenrieder.de
      Modules used:
      AdminThemeUIkit Table ProCache Markup Sitemap XML Email Obfuscation (EMO) Jumplinks Tracy Debugger Regards, Andreas
    • By modifiedcontent
      Dumb question coming up. I can't get sorting to work. I show child pages (posts) of a parent page (news) on the homepage with this in the template:
      $news = $pages->find("template=post"); foreach($news as $post) { ... Sort order setting in the template or page is apparently ignored. The sort order is correct in the admin area, but shows up wrong on the home page.
      What am I missing?
    • By Macrura
      Here is a recent site done in processwire:
      http://licoriceensemble.com/
      modules used include
      formbuilder procache cropimage version control for text fields after save actions based on a template by the great team at Elemis.
×
×
  • Create New...