Wednesday, 26 August 2020
  4 Replies
  1K Visits
0
Votes
Undo
Hi guys
Just wondering if you can point me in the right direction to modify this function. I use it to sort events by category and it works well. What I was hoping to do is add some code to the function to place one category first always.

The name of the category is Meeting and it has a category id number of 20.

Thanks for the help
Steve


// Sort events by category
function sortjeventsbycat($a,$b){
if ($a->getCategoryName() == $b->getCategoryName()){
if ($a->title() == $b->title()) {
return 0;
}
return ($a->title() < $b->title()) ? -1 : 1;
}
return $a->getCategoryName() < $b->getCategoryName() ? -1 : 1;
}
Thursday, 27 August 2020 11:12
·
#217769
0
Votes
Undo
something like this before line 10


if ($a->getCategoryName() == "Meeting")
return -1;
if ($b->getCategoryName() == "Meeting")
return 1;

should do it (but I haven't tested it)
Thursday, 27 August 2020 11:26
·
#217774
0
Votes
Undo
Thank you Geraint, I will give it a try.

Steve
Tuesday, 27 October 2020 11:04
·
#218894
0
Votes
Undo
Hey Steve,

Just checking how that worked out with you?

Many thanks
Tony
Wednesday, 28 October 2020 02:08
·
#218913
0
Votes
Undo
It worked perfectly Tony, thanks for checking.

Steve
  • Page :
  • 1
There are no replies made for this post yet.