keywords related_objects failing

Author Message

Luc Chase

Saturday 16 September 2006 7:54:49 pm

Have two objects <b>sharing the same keyword</b>, yet the related_ojects attribute is false for both. How can this be?

In <b>both</b> cases

 {$node.data_map.keywords.content|attribute(show)}

outputs...

Attribute 	    Type 	         Value
keywords 	array 	         Array(1)
>0 	            string 	     'Canada'
keyword_string 	string 	         'Canada'
related_objects boolean 	false
related_nodes 	boolean 	false

The Web Application Service Provider

Claudia Kosny

Wednesday 20 September 2006 1:08:36 pm

Hello Luc

For the moment just a few questions:
What version of EZ do you use?
What classes do the two objects in question have?
If you make a copy of one of the objects - do the two copies see each other as related?

Greetings from Luxembourg

Claudia

Luc Chase

Wednesday 20 September 2006 3:15:40 pm

Claudia,
What version of EZ do you use?
3.7.9

What classes do the two objects in question have?
One is similar to Article but with the 'keywords' attribute added and the other is a custom class called Country which also includes the 'keywords' attribute.

If you make a copy of one of the objects - do the two copies see each other as related?
No.

It looks to me that there is also a possible bug in the template code that displays relations in the admin siteaccess... but when I amend it, it seems to make no difference.

{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,
                                                             offset, $view_parameters.offset,
                                                             attribute_filter, $time_filter,
                                                             sort_by, $node.sort_array,
                                                             limit, $page_limit ) )}
 
{foreach $list as $element}   /* MAYBE THIS SHOULD BE foreach $list_items as $element  ? */
    {$element.link_object.name|wash} ({$element.keyword|wash}) <br />
{/foreach}


The Web Application Service Provider

Claudia Kosny

Friday 22 September 2006 3:42:16 pm

Hello Luc

I played around with it a bit and it seems that for classes to be related via keywords they must be of the same type. They also kind of mention this in the docu here

http://ez.no/doc/ez_publish/technical_manual/3_8/reference/datatypes/keywords

but it is not very clear. When you try a fetch for 'content' 'keyword' you nevertheless get all objects sharing this keyword, no matter the classtype they have.

But what I find really puzzling is that the two copies of the same object (or rather the original and the copy) do not see each other as related. For me (Ez 3.8.4) that worked just fine. If you know a bit about SQL I would suggest having a look at the ezkeyword tables to see whether there are any entries corresponding to your objects. Aaprt from that I unfortunately do not know what to do...

Greetings from Luxembourg

Claudia

Luc Chase

Saturday 23 September 2006 2:42:09 am

Claudia,
thanks for your reply. I had already checked the table before my post and they seem to be in order with correct records in the cross-reference table, etc. - don't remember the name of the two tables involved but it looked correct.
I had tried the fetch function but it did not return any values for me. Could you please post the fetch code you used that worked so I can try again?

The Web Application Service Provider

Claudia Kosny

Saturday 23 September 2006 11:27:40 am

Hello Luc

here is my test setup:
all nodes have the same keyword 'fate'
nodes 90 and 91 are of the class
nodes 92 and 93 are of the same class

{* this returns all four entries *}
{def $sameKeywordsArr = fetch('content', 'keyword', hash('alphabet', 'fate'))}
{foreach $sameKeywordsArr as $keywordObj}
{$keywordObj.link_object.name} - {$keywordObj.link_object.node_id}<br />
{/foreach}

{* now check each node on its own *}
{def $node90 = fetch('content', 'node', hash('node_id', 90))
$node91 = fetch('content', 'node', hash('node_id', 91))
$node92 = fetch('content', 'node', hash('node_id', 92))
$node93 = fetch('content', 'node', hash('node_id', 93))}

{* returns 91 *}
{$node90.data_map.keywords.content.related_nodes[0].node_id}
{* returns 90 *}
{$node91.data_map.keywords.content.related_nodes[0].node_id}

{* returns 93 *}
{$node92.data_map.keywords.content.related_nodes[0].node_id}
{* returns 92 *}
{$node93.data_map.keywords.content.related_nodes[0].node_id}

You might also want to check the SQL-output generated by the retrieving of the keyword attribute.
A good way to this lik this:
{def $dataMap = $node93.data_map}
{debug-timing-point id="foobar"}
{$dataMap.keywords.content.related_nodes[0].node_id}
{/debug-timing-point}

Then just have a look at the queries between the start and the end of the timing point.

Greetings from Luxembourg

Claudia

Luc Chase

Saturday 23 September 2006 2:24:33 pm

Claudia,
although I could not get any value from
{$node91.data_map.keywords.content.related_nodes[0].node_id}

The preceeding code worked fine and produced a list of nodes with keywords in common, but....
mysteriously it doesn't work any longer. I now get a SQL syntax error.

{def $sameKeywordsArr = fetch( 'content', 'keyword', hash( 'alphabet', 'uk' ) ) }


{foreach $sameKeywordsArr as $keywordObj}
      {$keywordObj.link_object.name}  - {$keywordObj.link_object.node_id} <br/>
{/foreach}


returns this error...

Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') or () or ()) 
                      AND ezcontentclass.version=0
             ' at line 4. Query: SELECT ezkeyword.keyword,ezcontentobject_tree.node_id
                      FROM ezkeyword, ezkeyword_attribute_link,ezcontentobject_tree,ezcontentobject,ezcontentclass, ezcontentobject_attribute
                      WHERE ezkeyword.keyword LIKE 'uk%'
                       AND (() or () or ()) 
                      AND ezcontentclass.version=0
                      AND ezcontentobject.status=1
                      AND ezcontentobject_attribute.version=ezcontentobject.current_version
                      AND ezcontentobject_tree.main_node_id=ezcontentobject_tree.node_id
                      AND ezcontentobject_attribute.contentobject_id=ezcontentobject.id
                      AND ezcontentobject_tree.contentobject_id = ezcontentobject.id
                      AND ezcontentclass.id = ezcontentobject.contentclass_id
                      AND ezcontentobject_attribute.id=ezkeyword_attribute_link.objectattribute_id
                      AND ezkeyword_attribute_link.keyword_id = ezkeyword.id ORDER BY ezkeyword.keyword ASC


weird.

The Web Application Service Provider

Luc Chase

Saturday 23 September 2006 3:31:23 pm

Now it's working again. Same code. All I did was clear cache again.

Looks like the $node.data_map.keywords.content.related_objects and $node.data_map.keywords.content.related_nodes have nothing to do with keyword relations, but are only concerned with explicit relations through the relation or relations attribute type.

The Web Application Service Provider

Claudia Kosny

Sunday 24 September 2006 12:00:31 pm

Hi Luc

Looks like the $node.data_map.keywords.content.related_objects and $node.data_map.keywords.content.related_nodes have nothing to do with keyword relations, but are only concerned with explicit relations through the relation or relations attribute type.

This is definitely not the case for me, the nodes/objects in my example did not have any other relations at all so the relation was only created by the shared keyword.

The part in your SQL statement that caused problems is usually related to permission and owner checking so you might want to try whether it makes any difference if you are logged in as admin or not. Also make sure (at least for testing) that the objects that should be related via keywords do not have different access permissions and are in the same section.

Actually I just realised that I do not know the version of EZ you use. If it is an older version you might want to test your setup on the newest version - maybe the problem was fixed meanwhile.

In case it helps find below the sql output I get when I do the following:

{def $node93 = fetch('content', 'node', hash('node_id', 93))}
{def $dataMap = $node93.data_map}
{debug-timing-point id="foobar"}
{$dataMap.keywords.content.related_nodes}
{/debug-timing-point}
debug-timing-point START: foobar

Notice: eZMySQLDB::query(1 rows, 2.846 ms) query number per page:4 	Sep 24 2006 19:59:17

SELECT ezkeyword.keyword FROM ezkeyword_attribute_link, ezkeyword
                                    WHERE ezkeyword_attribute_link.keyword_id=ezkeyword.id AND
                                    ezkeyword_attribute_link.objectattribute_id='352'

Notice: eZMySQLDB::query(1 rows, 1.366 ms) query number per page:5 	Sep 24 2006 19:59:17

SELECT * FROM ezkeyword_attribute_link
                                    WHERE objectattribute_id='352'

Notice: eZMySQLDB::query(1 rows, 1.969 ms) query number per page:6 	Sep 24 2006 19:59:17

SELECT DISTINCT ezcontentobject_attribute.contentobject_id FROM ezkeyword_attribute_link, ezcontentobject_attribute
                                                  WHERE keyword_id IN ( 28 ) AND
                                                        ezcontentobject_attribute.id = ezkeyword_attribute_link.objectattribute_id
                                                        AND  objectattribute_id <> '352'

Notice: eZMySQLDB::query(1 rows, 1.967 ms) query number per page:7 	Sep 24 2006 19:59:17

SELECT ezcontentobject.*,
                           ezcontentobject_tree.*,
                           ezcontentclass.name as class_name
                    FROM ezcontentobject_tree,
                         ezcontentobject,
                         ezcontentclass
                    WHERE ezcontentobject_tree.contentobject_id in ( 92 ) AND
                          ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id AND
                          ezcontentobject_tree.contentobject_id=ezcontentobject.id AND
                          ezcontentclass.version=0  AND
                          ezcontentclass.id = ezcontentobject.contentclass_id

Timing: 	Sep 24 2006 19:59:17

debug-timing-point END: foobar

Don't forget that for the related_nodes to work, the objects must have the same class.

Good luck

Claudia

Luc Chase

Wednesday 27 September 2006 2:35:54 am

Claudia,
I'm still working on this. But wondering if anyone has used the new (?) related_view_gui template function. Will need to sort and group my related objects and maybe related_view_gui may help with that.

The Web Application Service Provider

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