Why tag cloud showing tags from ALL languages?

Author Message

Olaf Fichtner

Sunday 02 May 2010 9:14:47 am

I am not sure if this is the right forum to ask, it appears I have a problem with the tag cloud, but I am not sure if this is a setting issue or a "feature"/bug. I came across eZ Publish because I need multiple languages and eZ Publish promised to be the way to go. After some exploration it seems however that the tag cloud is displaying tags from articles in all languages, which would not make much sense usually.

So I wonder, did I miss an important setting or is this indeed the actual/intended behaviour? I would very much prefer to only show tags belonging to articles in the currently selected language...

Robin Muilwijk

Sunday 02 May 2010 11:53:09 am

Hi Olaf,

That is a very good question, if this is a feature or perhaps a bug. I dug through some documentation and mainly this:

http://ez.no/doc/ez_publish/technical_manual/4_x/features/multi_language/configuring_the_site_languages

but could not find anything about the tag cloud and languages dependency. I'll try to contact some long time/experienced eZ users who might know more.

Regards Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Matthieu Sévère

Sunday 02 May 2010 12:51:56 pm

Yes indeed, I already had this issue and reported it : http://issues.ez.no/15723

You can hack a little bit in going into the code and fetch the language of each tag to do some post processing :

$rs = $db->arrayQuery( "SELECT ezkeyword.keyword, count(*), ezcontentobject_attribute.language_code as keyword_count .......

Cheers !

--
eZ certified developer: http://ez.no/certification/verify/346216

Olaf Fichtner

Sunday 02 May 2010 8:00:42 pm

Thank you both for the replies! So at least it is not me, but indeed the tag cloud.

Matthieu, unfortunately I am better with human languages than with the computer-related ones. I will gnaw my way through PHP code and perhaps even some SQL if absolutely necessary, but I hope there can be an official solution - so at least I confirmed your bug report...

Roberto Antoniazzi

Monday 03 May 2010 6:18:51 am

I tried solving with a trick.. in the tpl eztagcloud.tpl I added the language among the parameters:

{def $language = ezini('RegionalSettings', 'Locale', 'site.ini')}

{eztagcloud( hash( 'parent_node_id', $block.custom_attributes.subtree_node_id, 'limit', 40, 'sort_by', array('count', false()), 'post_sort_by', 'keyword', 'language', $language ))}

Then in the file

extension/ezwebin/autoloads/eztagcloud.php

I added

if ( isset( $params['language'] ) )
{
$language = $params['language'];
$languageFilter2 = "AND ezcontentobject_attribute.language_code = " . "'" . $language . "'";
}
else
{
$languageFilter2 = "";
}

Finally I added the variable $languageFilter2 to

$rs = $db->arrayQuery(.....)

Robin Muilwijk

Monday 03 May 2010 11:41:49 am

Hi Roberto,

Does this code work? If so, it might help a lot to add it as a comment on the issue Matthieu reffers to. If the developers pick this up, they can then check your code and implement it, or at least use (part of) it.

Thanks, Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Olaf Fichtner

Monday 03 May 2010 11:44:14 pm

Hmm, where is eztagcloud.tpl located? I could not find it, and it seems neither could the computer...

Roberto Antoniazzi

Tuesday 04 May 2010 1:06:06 am

@Robin: I'll add the code as soon as possible

@Olaf: I was wrong.. the standard position of the template is extension/ezwebin/design/ezwebin/templates/node/view/tagcloud.tpl

Olaf Fichtner

Tuesday 04 May 2010 3:42:41 am

Roberto,

Sorry, did not work for me. I found two instances of tagcloud.tpl that looked suitable (node/view) and modified both. Your code for eztagcloud.php was inserted after

if ( isset( $params['offset'] ) )
$dbParams['offset'] = $params['offset'];

and the filter I put here:

$sqlPermissionChecking[where]
$languageFilter
$languageFilter2

I flushed all caches, but the tag cloud still shows tags from all languages... :-(

Did I perhaps make a mistake somewhere?

Olaf Fichtner

Monday 10 May 2010 10:32:33 am

I am not quite fluent in PHP, but Roberto's code should probably insert a line like

AND ezcontentobject_attribute.language_code = 'ger-DE'

into the query in eztagcloud.php. I have now manually added such line and played with a few language codes and this actually worked! So it looks like somewhere in the previous code (if isset...) the language code does not get inserted for some reason.

Does anyone know how to debug the file to find out where the problem lies? I enabled debugging in site.ini.append.php, but there is no output of PHP variables.

Roberto Antoniazzi

Monday 10 May 2010 11:59:55 am

Olaf, as I wrote in my first post you have to pass (and set) the variable

$language

in the template 

extension/ezwebin/design/ezwebin/templates/node/view/tagcloud.tpl

(or better in an override of this template) with the following code:

{def $language = ezini('RegionalSettings', 'Locale', 'site.ini')}

{eztagcloud( hash( 'parent_node_id', $block.custom_attributes.subtree_node_id, 'limit', 40, 'sort_by', array('count', false()), 'post_sort_by', 'keyword', 'language', $language ))}

roberto

Olaf Fichtner

Monday 10 May 2010 9:28:53 pm

I tried that, Roberto, I'm not sure where something may have gone haywire... Below is my current tagcloud.tpl. (I hope it displays OK, each time I pasted the copied code it appeared twice - but the file itself seems to be OK...)

<div class="border-box"><div class="border-tl"><div class="border-tr"><div class="border-tc"></div></div></div><div class="border-ml"><div class="border-mr"><div class="border-mc float-break">

<div class="content-view-tagcloud">

{def $language = ezini('RegionalSettings', 'Locale', 'site.ini')}

{eztagcloud( hash( 'parent_node_id', $block.custom_attributes.subtree_node_id, 'limit', 40, 'sort_by', array('count', false()), 'post_sort_by', 'keyword', 'language', $language ))}

</div>

</div></div></div><div class="border-bl"><div class="border-br"><div class="border-bc"></div></div></div></div>

Roberto Antoniazzi

Tuesday 11 May 2010 1:28:45 am

did you chose the right template? it should be

extension/ezwebin/design/ezwebin/templates/node/view/tagcloud.tpl

(or its override) and NOT

extension/ezwebin/design/ezwebin/templates/tagcloud/tagcloud.tpl

try to see if the right value is passed to the php code, for example adding:

print($params['language']); exit();

inside the file

extension/ezwebin/autoloads/eztagcloud.php

Olaf Fichtner

Tuesday 11 May 2010 10:37:21 am

I guess I admit defeat on this. I must have made a mistake, but I can not find it.

Roberto, I suppose your modification works for you, so do you think you could attach the two modified files to the bug report, as suggested by Robin? That would be really nice. I would download the files from there and try once more with those...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.