Thxs a lot to explained me with clarity all of that and help me to understand 
better XWiki.
Then with what you give me, I tried to add a  format_date parameter () (or 
regexp) in columns properties to improve livetable.
I failed because I didn't manage to find where is store livetable macro :-))

Something like this and next add a format date parameter in user index 
customizer.
#set($columns = ["_avatar", "first_name", "last_name", "email", 
"doc.creationDate", "_actions"])
#set($columnsProperties = {
   "_avatar" : { "type" : "none", "link" : "none", "html" : "true", 
"sortable":false },
   "first_name" : { "type" : "text" , "size" : 20, "link" : "view"},
   "last_name" : { "type" : "text", "link" : "view"},
   "email" : { "type" : "text" },
    "doc.creationDate" : { "type" : "date", "dateformat":"YYYY-mm" }
})
#set($options = {
  "className":"XWiki.XWikiUsers",
  "translationPrefix" : "xe.index.users.",
  "tagCloud" : true,
  "rowCount": 10
})
#livetable("userdirectory" $columns $columnsProperties $options)
      De : Clemens Klein-Robbenhaar <c.robbenh...@espresto.com>
 À : users@xwiki.org 
 Envoyé le : Mardi 13 janvier 2015 12h22
 Objet : Re: [xwiki-users] Add date of account creation (without time) in User 
Index problem
   
On 01/13/2015 10:45 AM, Pascal BASTIEN wrote:
> Hello,
> 
> To make it work I add this new property in XWiki.XWikiUsers class:
> /bin/edit/XWiki/XWikiUsers?editor=class
> Name: doc.creationDate Type: String
> PrettyName: Creation date
> 

I did not know that you can create class properties with a dot in it,
and that this even can be used to get the original document property, but I see 
it indeed works

> Custom Display:
> {{velocity}}
> {{html}}<i>$value</i>{{/html}}
> {{/velocity}}
> 
> The problem is that "Custom display" is not taking into account and not 
> rendering.

This actually does not work, because the livetable ones not use the custom 
displayer at all,
but treats 'doc.creationDate' special

Possible solutions:

 1)
  - create a "dummy" class property, which does *not* shadow a doc-property,
  e.g. Name : "doccreationdate", Type: Date

  CustomDisplay
  {{velocity}}
  $xwiki.formatDate($doc.getCreationDate(),'yyyy/MM/dd')
  {{/velocity}}

 so the custom display does not display the value of the property at all, but 
the actual creation date

 - add 'doccreationdate' to the list of columns in the User Directory

This kinda works, except that you cannot sort by that fake "creation date", as 
it is not really there.
(The filter searching the database does not know about the custom displayer and 
searches for the empty value in the DB instead.)


2) Another alternative is to edit the place where "doc.creationDate" is 
actually rendered ...
for this you would have to patch the main livetable rendering.
see:

 http://localhost:8080/xwiki/bin/view/XWiki/LiveTableResultsMacros?viewer=code

around line 230 there is a:
  #set($discard = $row.put('doc_creationDate', 
$xwiki.formatDate($itemDoc.creationDate)))

you could change that to:
  #set($discard = $row.put('doc_creationDate', 
$xwiki.formatDate($itemDoc.creationDate, 'yyyy/MM/dd')))

and then add doc.creationDate to the list of displayed columns in the user 
directory.

However then all creation dates everywhere (well, everywhere in live tables) 
will be rendered "day only".
(Oh, and I see one still needs to add a dummy 'doc.creationDate' field to the 
user class, as otherwise the field is ignored :(


3) Finally the third solution I can think of would be to add a new date 
property to the user class,
and set this property to doc.creationDate whenever a user is created, and show 
this property in the User Directory
.
This might even be the cleanest solution, except that one needs to touch all 
existing users to update this field.

Newly created users then would be set up by writing an event listener that 
listens to a DocumentCreatingEvent
and if the new document has an XWiki.XWikiUsers object, then set the new 
property to doc.creaionDate

Event listener would be "components" as explained here:
  http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutorial
  http://extensions.xwiki.org/xwiki/bin/view/Extension/WikiComponent+Module

This is somewhat more effort, but I guess this would be "cleaner" (no custom 
display needed, just use the date format of that property,
results can be sorted, as value is really stored in the DB, no patching of 
"core" XWiki pages ...)




> I know HTML is not interpreted but I want to remove time of "Creation date" 
> field but "Custom Display" is apparently not used on a database field.
> Here a screenshot on what I want: http://snag.gy/bWnu9.jpg
> Do you have an idea how I must do it?
> Is it normal than "Custom Display" is not used?
> 
> Thxs for any help
> 
> Pascal BASTIEN
> 
> 
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
> 

_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


  
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to