Wednesday, 26 August 2020
  4 Replies
  572 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;
}
4 years ago
·
#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)

JEvents Club members can get priority forum support at the Support Forum. As well as access to a variety of custom JEvents addons and benefits. Join the JEvents club today!

4 years ago
·
#217774
0
Votes
Undo
Thank you Geraint, I will give it a try.

Steve
4 years ago
·
#218894
0
Votes
Undo
Hey Steve,

Just checking how that worked out with you?

Many thanks
Tony

JEvents Club members can get priority forum support at the Support Forum. As well as access to a variety of custom JEvents addons and benefits. Join the JEvents club today!Join the JEvents club today!

4 years ago
·
#218913
0
Votes
Undo
It worked perfectly Tony, thanks for checking.

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