Keyword

Tags not in alphabetical order in the available tags box

  • Phil Walton
  • Phil Walton's Avatar Topic Author
  • Offline
  • New Member
More
13 years 9 months ago #91918 by Phil Walton
Hi, really enjoying K2 and our first time using it for a client, although I have come across a few bugs which have been reported on this forum and seem to have remained unanswered , both for almost a year.

This particular one is mentioned in several bug posts and all remain unanswered. I cannot add to the posts as they are locked so have had to start a new one.

My question is, will this be fixed any time soon, is it deemed as not necessary or just missed.

Our client has 500 tags and is finding the random nature drives them mad. I agree with them that it does not help in grouping the tags to see if someone has already added it or added it with a capital or lowercase (both would in k2 produce a new tag and so split the key word in to two) resulting in articles being incorrectly tagged

 

There was a post and solution for this 11 months ago but no one responded to the chap and we are using latest k2 so its not been adopted. If Joomla works does not think it a bug then fine, I will patch it on mine, just would prefer to know one way or other so I don't do the changes and find its just been fixed and brought in to the code.

 

Kind regards

 

Phil

 

Previous post with solution

 

Hello All,

 

In K2 Item display the tags list is displayed by id rather than Alphabetically. Not sure if this is a "bug" but the SQL code in models/item.php getItemTags, line 694, should be:

 

$query="SELECT `id`, `name` FROM #__k2_tags as tags WHERE tags.published=1 AND tags.id IN (SELECT `tagID` FROM #__k2_tags_xref WHERE `itemID`={$itemID}) order by `name`";

 

Also in the administration area change the following functions in models/item.php...

 

    function getAvailableTags($itemID = NULL) {

        $db = &JFactory::getDBO();        $query = "SELECT * FROM #__k2_tags as tags";        if (!is_null($itemID))            $query .= " WHERE tags.id NOT IN (SELECT tagID FROM #__k2_tags_xref WHERE itemID={$itemID})";  $query .= " ORDER BY `name`";        $db->setQuery($query);        $rows = $db->loadObjectList();        return $rows;    }

    function getCurrentTags($itemID) {

        $db = &JFactory::getDBO();        $query = "SELECT * FROM #__k2_tags as tags WHERE tags.id IN (SELECT tagID FROM #__k2_tags_xref WHERE itemID={$itemID}) ORDER BY `name`";        $db->setQuery($query);        $rows = $db->loadObjectList();        return $rows;    }

 

Jw

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #91919 by Pieter
bump.

 

In my case, it doesn't work with new items, but if I open an item, the tags are ordered by name. Is there a different .php file for the new item??

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #91920 by Brian Bachtel
Hi Pieter,

 

I know this discussion is over a month old, but in case you haven't figured it out yet and for those coming here and seeing this you need to change the getAvailableTags function to this...

 

function getAvailableTags($itemID = NULL) {        $db = &JFactory::getDBO();

       $query = "SELECT * FROM #__k2_tags as tags";

        if (!is_null($itemID)){

        $query .= " WHERE tags.id NOT IN (SELECT tagID FROM #__k2_tags_xref WHERE itemID=".(int)$itemID.") ORDER BY tags.name";

        } else {

        $query .= " ORDER BY tags.name";

        }

        $db->setQuery($query);

        $rows = $db->loadObjectList();

        return $rows;

    }

 

Reason for the else is because a new article does not have an "itemID" yet so the ORDER BY was being ignored in the original code. Resulting in an unordered tag list in new articles. Adding the else statement takes care of this.

 

Hope this helps.

 

Brian
Pieter said:

bump.

 

In my case, it doesn't work with new items, but if I open an item, the tags are ordered by name. Is there a different .php file for the new item??

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #91921 by Pieter
Thanks, Brian, works like a charm. My users will be very happy!

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum