Hello!

This is an example of the code to modify the label of the "common" layout and 
how to translate it. To see how this code works, you should run it as an 
External Method and run zope from console (only if you want to see the printed 
output).

###########
def tutorial(self):
  #!python
  
  context = self
  messageCat = context.Localizer.default
  ttool = context.portal_types
  ltool = context.portal_layouts
  typeInfo = ttool['News Item']
  print ltool[typeInfo.layouts[0]]['Description'].is_i18n         
ltool[typeInfo.layouts[0]]['Description'].is_i18n = 0
  print ltool[typeInfo.layouts[0]]['Description'].is_i18n 
  print ltool[typeInfo.layouts[0]]['Description'].label 
  newLabel = 'label_mylabel'
  ltool[typeInfo.layouts[0]]['Description'].label =  newLabel
  print ltool[typeInfo.layouts[0]]['Description'].label 
  
  labelTranslation = 'My Label'
  messageCat.gettext(newLabel,'es',add=1)
  messageCat.manage_editMessage(newLabel, 'es', labelTranslation, None, None) 
###########

For your use case, I would:
1.- Create a method inside PropertiesTool.py which recieves the new labels as 
parameter and modifies the corresponding layout ("members").
2.- Modify the code that updates portal properties to call your new method.

Maybe this is not the best solution, but I hope this helps ;-) I'll wait for 
your comments.

Regards.


Hello hi,

Two questions about widgets and layouts and schemas...

1/ I have a member schema with 3 "custom" zones (CPS String fields). I'd
like to use portal properties to set the labels of the corresponding
widgets (String widgets or like), so the portal admin can set whatever
label pleases him. Is there an easy way to do so ? I failed to
understand exactly how a string widget is rendered (didn't found a .pt,
and the render() method of string widget seems to only care about the
content, not the label... or did I miss something ?)

2/ I have what I thought would be a common use case : for a given (CPS
String) field, propose the user a selection list *and* a text input for
values that are not in the list. But I failed to find a widget doing
this. Does such a beast exist ? Or is this problem best solved by using
two widgets (a selection and a string widget) and using write expression
to retrieve the value from the appropriate widget ?

TIA
-- 
bruno desthuilliers
développeur
[EMAIL PROTECTED]
http://www.modulix.com
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to