getk2 / k2

K2 - the powerful content extension for Joomla
https://getk2.org
GNU General Public License v3.0
135 stars 94 forks source link

K2 Tags and Multilanguage Site #310

Closed AlexanderSk closed 2 years ago

AlexanderSk commented 8 years ago

Hello (καλησπέρα),

The issue with a multilingual site that has tags enabled with SEF is that on the main language (default) TAGS are working as expected and on the secondary language (in my case Greek) tags show a 404 page.

I also found the following page that presents the same case and menetions this only occurs when SEF is enabled ( i did not test this ). http://joomla.stackexchange.com/questions/13814/joomla-k2-tags-dont-work-with-sef

Joomla 3.51 latest K2: 2.7 latest php 5.6 Apache 2.4

teobgeno commented 8 years ago

I am trying to reproduce the issue with the same settings and languages as yours but in my case everything function properly. Can you provide a link ?

AlexanderSk commented 8 years ago

Update: In my case i am talking about k2 items without any parent category as a blog like (K2 » Item listings » Categories).

The two following pages have the same settings, K2 » Item » Item

Tags working here: https://www.digi-web.gr/en/corporate-website

Tags dont work. here: https://www.digi-web.gr/el/%CE%B5%CF%84%CE%B1%CE%B9%CF%81%CE%B9%CE%BA%CF%8C-web-site

Ps 1)The web page is using ajax but it does not interefere to this process as you may open the link in a new window with a 404 error as well. 2) The pages that do have a parent blog catagory tags are working OK with either language.

What do you think?

kavadas commented 8 years ago

@AlexanderSk Does the tag "ιστοσελίδα" exist on your site? Is it published? You can check that at the K2 administration area at the tags list. Finally, since this menu is configured for the Greek language, are there any K2 items assigned to Greek language? I assume that you are using the native Joomla multilanguage features.

AlexanderSk commented 8 years ago

Hello,

With one more careful look i found out these tags are actually translated with Falang, tags that are created with actual K2 component seem to be working correctly. Please close the topic i will post this on fa-lang community as an issue.

AlexanderSk commented 7 years ago

After so many months i found some time to further debug this properly.

I found out that the issue is caused by the k2 component from a part of code that is inserted as a spam prevention measure.

On the file: components/com_k2/views/itemlist/view.html.php On lines 278 up to 286 you may see the actual checking that is made. Since the tag is translated into the falang component the query will fail and a 404 error page will be shown.

I have also forwarded this to falang team... Edit: I think falang cannot fix it since the issue is on the view file. Re-open Request.

A solution could be to place the code into a class function so fa-lang and other plugins could override it.

kcpr-raffaEl commented 6 years ago

For me changing part of components/com_k2/views/itemlist/view.html.php code mentioned by AlexanderSk to this helped:

$tag = JRequest::getString('tag');
$db = JFactory::getDBO();
$db->setQuery('SELECT id, name FROM #__k2_tags WHERE name = '.$db->quote($tag));
$tag = $db->loadObject();
if (!$tag || !$tag->id) {
    $db->setQuery('SELECT id, value FROM #__falang_content WHERE value = '.$db->quote($tag));
    $tag = $db->loadObject();
    if (!$tag || !$tag->id) {
        JError::raiseError(404, JText::_('K2_NOT_FOUND'));
        return false;
    }
}
fevangelou commented 4 years ago

Added a better check in K2 v2.10.3 (dev): https://github.com/getk2/k2/commit/b22678558ab3ddfe041631a60674ceb27c9b0519