- Posts: 45
COMMUNITY FORUM
Sort itemAuthorLatest in itemView by custom field
- Gerben
-
Topic Author
- Offline
- Senior Member
I know how to sort the items (to create a menu item and link it to a user)
How can this be done for all the users in once? I made a custom field in the database that users can update so they can set the items on top of there page.
I have the same problem on the userView page. The items in the userItemList are sorting by date but i want to sort them by custom field.
Where can i set this to a custom database field?
Really looking forward to a answer to this, trying to find a solution for a week but just can't find it :)
Geppie
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
By default K2 does not support this functionality, however there are several extensions posted ad the JED or at the extend K2 section of this site that offer filtering from extrafields.
Please Log in or Create an account to join the conversation.
- Gerben
-
Topic Author
- Offline
- Senior Member
- Posts: 45
Thank you for your quick reply. I found a way to filter the itemAuthorLatest items.
I did this by modify the models/itemlist.php
function getAuthorLatest and then added ORDER BY i.neworder ASC"; on row 856
But i can not find the way how the sort to userItemList in the userview.
Do you know where i can find this or add this option?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Although I strongly recommend you against doing this because it is a core hack.
In the next update you will lose all of your changes and you wlll need to reapply them.
Please Log in or Create an account to join the conversation.
- Gerben
-
Topic Author
- Offline
- Senior Member
- Posts: 45
I found the case user but can't see where to put the "ORDER BY i.neworder ASC"
I will keep on trying :) Can you give me another push in the right direction?
Thanks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Gerben
-
Topic Author
- Offline
- Senior Member
- Posts: 45
$query .= " AND i.created_by={$id} AND i.created_by_alias='' ";
Must be this?
$query .= " AND i.created_by={$id} AND i.created_by_alias=' ' ORDER BY i.neworder ASC" ;
But is not working..
Please Log in or Create an account to join the conversation.
- Gerben
-
Topic Author
- Offline
- Senior Member
- Posts: 45
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Make sure these predefined values are not overriding your query, eg. make sure the 'user' case is not inheriting these values.
Please Log in or Create an account to join the conversation.
- Gerben
-
Topic Author
- Offline
- Senior Member
- Posts: 45
I added to the ordering switch ($ordering)
case 'neworder' :
$orderby = 'i.neworder ASC';
break;
But how can i insert this into the case 'user' ?
It's breaking my mind for more then a week now :D
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Is the case == user
do the custom ordering
else for all other cases
$query .= " ORDER BY ".$orderby;
Line 337 approx.
Please Log in or Create an account to join the conversation.
- Gerben
-
Topic Author
- Offline
- Senior Member
- Posts: 45
Fixed it with this:
if ($task == 'user')
{
$query .= " ORDER BY i.neworder ASC";
}
else{
$query .= " ORDER BY ".$orderby;
}
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Remember to back it up so you won't lose it.
Please Log in or Create an account to join the conversation.