/ Published in: Python
This is a general purpose Zope script for your Plone product or Plone custom skin folder. It provides LinugaPlone translation of references, either incoming, outgoing, or both.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
## Script (Python) "getTranslatedRefs" ##title=Gets translated refs, backrefs, or both for a given relationship. ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=rel,which,sort_on=None,sort_type=None,sort_order=None if which == "refs": refs = context.getCanonical().getRefs(relationship=rel) elif which == "brefs": refs = context.getCanonical().getBRefs(relationship=rel) elif which == "all": refs = context.getCanonical().getRefs(relationship=rel) + \ context.getCanonical().getBRefs(relationship=rel) else: raise "Invalid 'which' parameter %s - must be 'refs','brefs' or 'all'." unique = [] for b in refs: canonical = b.getCanonical() if canonical not in unique: unique.append(canonical) translated = [i.getTranslation(context.getLanguage()) or i for i in unique] if sort_on: results = sequence.sort(translated,((sort_on, sort_type, sort_order),)) else: results = translated return results