Friday 10 March 2006 2:18:50 pm - 9 replies
Hi all,
just a quick question to kick off the weekend!
I have added an attribute "active" to the user class. This is not set by default.
Now I need to set it programmicaly from an externsion. I don't know the nodeid or the objectid, but i know the phonenumber (which also was added to the user class as an attribute).
So I gather I need to fetch the user with the given phonenumber and then update the active-attribute of that user.
Any help might make my weekend pleasant!
Felix
Sunday 12 March 2006 9:07:00 am
Hi
This depends a bit on what kind of attribute it is, but I guess it's a boolean/checkbox in your case. Here is how to do it:
$object = eZContentObject::fetch( <object_id> ); $dataMap = $object->attribute( 'data_map' ); $active = $dataMap['<class attribute identifier>']; // Guess 'active' is your case $active->setAttribute( 'data_int', <0|1> ); $active->sync();
Modified on Tuesday 03 April 2007 3:01:31 pm by Kåre Køhler Høvik
Monday 13 March 2006 1:45:14 pm
Hi Felix
You can use the subtree function in content object tree node. Example :
$node = eZContentObjectTreeNode::subtree( 'AttributeFilter' =>
array( array( 'user/number', '=', '12345678' ) ) ), <parent node id> );
$object = $node->attribute( 'object' );
See also : http://ez.no/doc/ez_publish/techn...modules/content/fetch_functions/list
Monday 13 March 2006 2:31:38 pm
Hi again,
thank you again!
The code returned a
unexpected T_DOUBLE_ARROW
I think I solved it by changing the code to
$node = eZContentObjectTreeNode::subtree( array('AttributeFilter' => array( array( 'user/mobiltelefon', '=', _a_real_phone_number_))), 125 );
But now the problem is that it ruturns nothing. I also tried to change the attribute and fetch by the login-name, but it gave the same result.
Felix
Modified on Monday 13 March 2006 2:32:03 pm by Felix Laate
Monday 13 March 2006 2:57:22 pm
Hi Kåre,
125 is the NODE id where the users I want to fetch amongst are.
Here is the SQL output:
SELECT ezcontentobject.*,
ezcontentobject_tree.*,
ezcontentclass.name as class_name,
ezcontentclass.identifier as class_identifier
, ezcontentobject_name.name as name, ezcontentobject_name.real_translation
FROM
ezcontentobject_tree,
ezcontentobject,ezcontentclass
, ezcontentobject_name
, ezcontentobject_attribute a0
WHERE
path_string like '/1/5/125/%' and
a0.contentobject_id = ezcontentobject.id AND
a0.contentclassattribute_id = 238 AND
a0.version = ezcontentobject_name.content_version AND
a0.language_code = ezcontentobject_name.real_translation AND
( a0.sort_key_string = 12345678) AND
ezcontentclass.version=0 AND
node_id != 125 AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id AND
ezcontentclass.id = ezcontentobject.contentclass_id AND
ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and
ezcontentobject_name.content_translation = 'nor-NO'
AND ezcontentobject_tree.is_invisible = 0
AND ((ezcontentobject.section_id in (1)) OR (ezcontentobject.section_id in (3)))
ORDER BY path_string ASC
"mobiltelefon" is text line.
Felix
Modified on Monday 13 March 2006 2:57:43 pm by Felix Laate
Wednesday 15 March 2006 12:16:05 pm
Hi again,
just wanted to tell you that I figured out what the problem was.
The object(s) I wanted to fetch was situated in the users section, and I guess the <i>eZContentObjectTreeNode</i> class is the wrong class to use to fetch something from there.
Had a look at the <i>eZUser</i> class, but couldn't find anything to meet my needs. So I moved the objects into the content structure.
Now it works, but I'm not completly satisfied as the objects really belong to the user section.
Felix
Modified on Wednesday 15 March 2006 12:16:58 pm by Felix Laate
Tuesday 03 April 2007 3:05:25 pm
Example for selection datatype, updating selection index from 3 to 4:
$dataMap = $object->attribute( 'data_map' );
$active = $dataMap['status'];
if ($active->attribute( 'data_text' ) == '3')
{
$active->setAttribute( 'data_text', '4' );
$active->sync();
}
You must be logged in to post messages in this topic!