0

Me and a colleague are developing a website using joomla, we have ditched the joomla article component and replaced it with K2.

A part of the site's content , is posting (using K2 items) upcoming Live Events, such as an upcoming music concert, containing info about that event, images etc.

We want to find out if its possible to order these items, by the Date of the Event, or in other words how to order these items by the Extra Field : Date, of the item. K2 core only let's us order these items by Date Published or Date Created which is not what we need.

If anyone knows an easy way to overcome this obstacle it will be deeply appreciated!

ktharsis
  • 3,160
  • 1
  • 19
  • 30
Ryan Di
  • 33
  • 3
  • 8

2 Answers2

1

we have been working on exactly the same events issue. K2 does not allow this, but we found a way of doing this in k2. The solution is an override of the template, but just one line is added. Our events section is here vida latina events , there is 1 extra field "date". We wanted to order by this field (this solution would work for any other extra field too).

Solution Create a menu item linking to an empty article. Create a module k2 contents that selects from your k2 category, that appears on your new empty page For "Order by", select "Title alphabetical" - we use this as we are going to hack it - so it needs to be an order you will not use for any other module Open the file modules/mod_k2_content/helper.php on line 195 find the code

case 'alpha' : $orderby = 'i.title DESC'; break;

and replace with:

case 'alpha' : $orderby = 'i.extra_fields DESC'; break;

This will work if you only have one extra field. If you have more than one extra field, you will have to modify the solution, but I think you get the general idea.

Hope this helps Jeyjoo

user1810211
  • 55
  • 1
  • 2
  • 11
0

I'm working on a similar project-making an event calendar using K2. I had the same question. What I am going to do is - for an event that is on Sept 22 2012, I will set the creation date at Sept 22 2011 (a year before). Then I will set K2 to order by "creation date" and set creation date to be hidden. This seems like a perfect solution...the only problem would be a leap year date (February 29) BUT you could set creation date to Feb 28 of the year before, and use the hours and minutes to get correct order that one day. I hope this makes sense.

Pete
  • 1