| Author | Message | 
                                                                                                    
                                                        | paul harvey
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Thursday 19 February 2004 10:42:41 am 
                                                                
                                                                 Hi Does anyboy know how i can use the current logged in user name to fill in the Author field of the comments class?  Paul | 
                                                
                                                                                                                                                        
                                                        | Alex Jones
                                                                                                                             | Thursday 19 February 2004 1:55:57 pm 
                                                                 This is a bit of a guess as I haven't messed with users myself, but you might be able to try sometihng like: 
{let current_user=fetch('user','current_user') }
<input value="{$current_user.name}" />
{/let}
If that doesn't work, you can view all of the attributes of <i>$current_user</i> by including the code <i>{$current_user|attribute(show)}</i> within your opening and closing <i>let</i> tags, which should help you track down the value you need. Alex Alex[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]
 
 <i>When in doubt, clear the cache.</i>
 | 
                                                                                                    
                                                        | paul harvey
                                                                                                                             | Friday 20 February 2004 2:49:20 am 
                                                                 ok that gets me a bit closer by using {$current_user.contentobject.name} in a standard form. but when i try to replace the attribute_edit_gui line in the following code with the ==new code== listed below my text edit box display the name but when i post the data is not sent.  
==existing code=={let author_attribute=$content_attributes_data_map.author}
 <div id="subject">
 <label>Subject</label><div class="labelbreak"></div>
 <input type="hidden" name="ContentObjectAttribute_id[]" value="{$author_attribute.id}" />
 {attribute_edit_gui attribute_base=$attribute_base attribute=$author_attribute}
 ==existing code==
 
==new code=={let current_user=fetch('user','current_user') }
 {attribute_edit_gui attribute_base=$attribute_base attribute=$current_user.contentobject.name}
 {/let}
 ==new code==
 | 
                                                                                                    
                                                        | Alex Jones
                                                                                                                             | Friday 20 February 2004 6:48:13 am 
                                                                 When you view the HTML source output by eZ, what does your hidden input tag contain? 
 <input type="hidden" name="ContentObjectAttribute_id[]" value="{$author_attribute.id}" />
Alex Alex[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]
 
 <i>When in doubt, clear the cache.</i>
 | 
                                                                                                    
                                                        | paul harvey
                                                                                                                             | Saturday 21 February 2004 4:29:56 pm 
                                                                 thanks for your help alex. I have had a few days off of this and given it a bit of thoughts.  
1./ my users will be logged in2./ I have setup permissions to the comment class to aloow create and edit and self
 3./ When the user posts they should become the owner of the object
 4./ i hoped that {$node.subtree|attribute(show,2)} would spit out the creator.name but it does not :( i just get a smaller subset of information for the subtree objects. please see below:
 
i think the line >creator 	object[ezcontentobject] 	Object
 is of interest and my suspision lead me to think that the creator/owner is the ezcontentobject
 
Attribute 	Type 	Value0 	object[ezcontentobjecttreenode] 	Object
 >node_id 	string 	108
 >parent_node_id 	string 	47
 >main_node_id 	string 	108
 >contentobject_id 	string 	175
 >contentobject_version 	string 	2
 >contentobject_is_published 	string 	1
 >depth 	string 	3
 >sort_field 	string 	9
 >sort_order 	string 	1
 >priority 	string 	0
 >path_string 	string 	'/1/2/47/108/'
 >path_identification_string 	string 	'news/test'
 >name 	string 	'test'
 >data_map 	array 	Array(7)
 >object 	object[ezcontentobject] 	Object
 >subtree 	array 	Array(1)
 >children 	array 	Array(1)
 >children_count 	string 	1
 >contentobject_version_object 	object[ezcontentobjectversion] 	Object
 >sort_array 	array 	Array(1)
 >creator 	object[ezcontentobject] 	Object
 >path 	array 	Array(2)
 >path_array 	array 	Array(4)
 >parent 	object[ezcontentobjecttreenode] 	Object
 >url 	string 	'news/test'
 | 
                                                                                                    
                                                        | Alex Jones
                                                                                                                             | Monday 23 February 2004 6:51:39 am 
                                                                 Paul, try using <i>attribute(show)</i> instead of <i>attribute(show,2)</i>. This should ensure you see every attribute of the object. I believe the owner/creator will be included in the expanded information. Alex Alex[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]
 
 <i>When in doubt, clear the cache.</i>
 | 
                                                                                                    
                                                        | paul harvey
                                                                                                                             | Monday 23 February 2004 2:06:03 pm 
                                                                 thanks alex attribute(show,3) gets it. now i just need to work out how to access it with my code. i will have a look one night this week if i get time :) | 
                                                                                                    
                                                        | paul harvey
                                                                                                                             | Monday 23 February 2004 2:52:03 pm 
                                                                 
Alex Got it...I used a couter couter=0 in the let statement and this to pull it out.
 {$node.subtree.$:counter.creator.name}
 {set counter=$:counter|inc}
 thanks for your help. If nothing else i learnt a lot working this out, especially though the debug output.  | 
                                                                                                    
                                                        | liu spider
                                                                                                                             | Monday 23 February 2004 5:57:20 pm 
                                                                 if you specified only logined users can add comments, then I think a better way to achieve this is as follows: remove the username and email attributes from commment class, and only leave the title and body attributes. Then as every object created will link to its creator, so you can find out later which user is the owner of a particular comment, and all the information you stored in the content object of this user. http://liucougar.scim-im.orgSCIM Input Method Platform
 http://scim.sf.net
 SJSD Online Editor
 http://sf.net/projects/sjsd
 | 
                                                                                                    
                                                        | paul harvey
                                                                                                                             | Tuesday 24 February 2004 1:05:30 am 
                                                                 liu Thats exactly what we have got to on the post above yours, please have another read of it. Now I will make a new comment class leaving the old one to allow for future ez upgrades. 
thanksPaul
 | 
                                                                                                    
                                                        | Alex Jones
                                                                                                                             | Tuesday 24 February 2004 5:47:16 am 
                                                                 Paul, I am glad you got it up and running. Using <i>attribute(show)</i> and working through each of the levels taught me a lot to say the least!  Alex Alex[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]
 
 <i>When in doubt, clear the cache.</i>
 |