- Posts: 17
COMMUNITY FORUM
Item Navigation order alphabetically
- Filipe Madeira
-
Topic Author
- Offline
- New Member
Less
More
8 years 11 months ago #154734
by Filipe Madeira
Item Navigation order alphabetically was created by Filipe Madeira
Hi there guys,
Does anyone knows how to make Item Navigation in Item View alphabetically?
In my category View, I have my items ordered alphabetically, and it would be nice to have them ordered that way when navigate in items.
Of course, ideally, this Item Navigation should respect always the category ordering:
If in Category A, items are ordered by ID, in Item Navigation should be also by ID.
If in Category B, items are ordered alphabetically, in respective items Item Navigation should be ordered alphabetically.
Does anyone have a clue on this?
i don't mind to loose Update Capability of K2 to achieve this, i guess next big update should be K2 3.0 and maybe this would be a native feature...
Many thanks in advance.
Joomla 3.5.1
K2 2.7.0
Does anyone knows how to make Item Navigation in Item View alphabetically?
In my category View, I have my items ordered alphabetically, and it would be nice to have them ordered that way when navigate in items.
Of course, ideally, this Item Navigation should respect always the category ordering:
If in Category A, items are ordered by ID, in Item Navigation should be also by ID.
If in Category B, items are ordered alphabetically, in respective items Item Navigation should be ordered alphabetically.
Does anyone have a clue on this?
i don't mind to loose Update Capability of K2 to achieve this, i guess next big update should be K2 3.0 and maybe this would be a native feature...
Many thanks in advance.
Joomla 3.5.1
K2 2.7.0
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 11 months ago #154811
by Krikor Boghossian
Replied by Krikor Boghossian on topic Item Navigation order alphabetically
Hello Filipe,
We are looking into this.
I have not forgotten about you.
We are looking into this.
I have not forgotten about you.
Please Log in or Create an account to join the conversation.
- Filipe Madeira
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 17
8 years 11 months ago #154817
by Filipe Madeira
Replied by Filipe Madeira on topic Item Navigation order alphabetically
Thanks Krikor!
I think this should be a great feature for K2.
Looking forward to hear news from you guys!
Thanks a lot!
I think this should be a great feature for K2.
Looking forward to hear news from you guys!
Thanks a lot!
Please Log in or Create an account to join the conversation.
- JoomlaWorks Support Team
-
- Offline
- Elite Member
Less
More
- Posts: 169
8 years 11 months ago #154819
by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Item Navigation order alphabetically
Hello Filipe,
The next and previous navigation depends on the ordering value of the K2 item you are currently in. For example if the current K2 item has ordering 3 the previous item will be the one which belong of course to the same category as the current one and has an ordering value of 2. As you understand the next item's ordering value is 4.
Now this functionality relies on two seperate functions at components/com_k2/models/item.php
and
Inside each of those functions there are a set of queries which controls the navigation. For example the getNextItem function with the query below
is fetching the data of the next item. Try to change the ORDER BY ordering value of the query with the one you want to (e.x ORDER BY created). As you understand you need to change this value to all the queries in those 2 functions I mentioned. Keep in mind also that I have not tested all that and by altering those 2 functions you are hacking the core of the extension.
The next and previous navigation depends on the ordering value of the K2 item you are currently in. For example if the current K2 item has ordering 3 the previous item will be the one which belong of course to the same category as the current one and has an ordering value of 2. As you understand the next item's ordering value is 4.
Now this functionality relies on two seperate functions at components/com_k2/models/item.php
function getPreviousItem($id, $catid, $ordering)
and
function getNextItem($id, $catid, $ordering)
Inside each of those functions there are a set of queries which controls the navigation. For example the getNextItem function with the query below
$query = "SELECT * FROM #__k2_items WHERE id != {$id} AND catid={$catid} AND ordering < {$ordering} AND published=1 AND ( publish_up = ".$db->Quote($nullDate)." OR publish_up <= ".$db->Quote($now)." ) AND ( publish_down = ".$db->Quote($nullDate)." OR publish_down >= ".$db->Quote($now)." ) {$accessCondition} AND trash=0 {$languageCondition} ORDER BY ordering DESC";
is fetching the data of the next item. Try to change the ORDER BY ordering value of the query with the one you want to (e.x ORDER BY created). As you understand you need to change this value to all the queries in those 2 functions I mentioned. Keep in mind also that I have not tested all that and by altering those 2 functions you are hacking the core of the extension.
Please Log in or Create an account to join the conversation.
- Filipe Madeira
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 17
8 years 11 months ago #154822
by Filipe Madeira
Replied by Filipe Madeira on topic Item Navigation order alphabetically
Hi Teo,
Great news from your support!
I've tried it, and all works well with id, created, ordering... But doesn't work with title or alias....
None of them works, how can I make it work alphabetically?
Thanks!
Great news from your support!
I've tried it, and all works well with id, created, ordering... But doesn't work with title or alias....
...ORDER BY title DESC";
...ORDER BY title ASC";
None of them works, how can I make it work alphabetically?
Thanks!
Please Log in or Create an account to join the conversation.
- JoomlaWorks Support Team
-
- Offline
- Elite Member
Less
More
- Posts: 169
8 years 11 months ago #154883
by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Item Navigation order alphabetically
Can you share a link in order to understand what you are getting back from the database query ?
Please Log in or Create an account to join the conversation.
- Filipe Madeira
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 17
8 years 11 months ago #154903
by Filipe Madeira
Replied by Filipe Madeira on topic Item Navigation order alphabetically
Hi Teo,
Thanks for your reply.
I don't think I can get you a URl of this PHP file, but is the same you mentioned:
Now this functionality relies on two seperate functions at components/com_k2/models/item.php
and the query for next item is:
At the end where:
If I change to:or
It wont order alphabeticaly, only works with ordering, id or date. Is it possible to work by the title?
Many thanks!
Thanks for your reply.
I don't think I can get you a URl of this PHP file, but is the same you mentioned:
Now this functionality relies on two seperate functions at components/com_k2/models/item.php
and the query for next item is:
$query = "SELECT * FROM #__k2_items WHERE id != {$id} AND catid={$catid} AND ordering < {$ordering} AND published=1 AND ( publish_up = ".$db->Quote($nullDate)." OR publish_up <= ".$db->Quote($now)." ) AND ( publish_down = ".$db->Quote($nullDate)." OR publish_down >= ".$db->Quote($now)." ) {$accessCondition} AND trash=0 {$languageCondition} ORDER BY ordering DESC";
At the end where:
...ORDER BY ordering DESC
If I change to:
ORDER BY title DESC
ORDER BY alias DESC
It wont order alphabeticaly, only works with ordering, id or date. Is it possible to work by the title?
Many thanks!
Please Log in or Create an account to join the conversation.