Menu

#13 PloneSiteMap: Do not show all translations

closed-works-for-me
nobody
None
3
2006-05-24
2005-05-11
No

Here is a quick patch for PloneSiteMap to make it not
show items not belonging to the currently selected
language. If you have a folder contact and a translated
version contact-de then PloneSiteMap should only show
one of these. This patch is usable with LinguaPlone.

---
/opt/ZEnv/ExtraProducts/PloneSiteMap/skins/PloneSiteMap/getSiteMap.py
2004-11-20 15:20:01.000000000 +0100
+++
/opt/ZEnv/AnthillProducts/AnthillCMS/skins/ant_core_scripts/getSiteMap.py
2005-05-11 12:33:02.000000000 +0200
@@ -1,7 +1,12 @@
-## Script (Python) "PloneSiteMap"
+## Script (Python) "getSiteMap"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
##parameters=root=None, metaTypesToDig=['Plone
Folder'], metaTypesNotToList=[],
statesToList=['published'], idsNotToList=['Members'],
depth=3, sortAlphabetically=1
##title=Generate the map of the site
-
+##
from Products.CMFCore.utils import getToolByName
siteMap=[]
@@ -28,6 +33,9 @@
if object_type == 'I18NLayer' and object_type
!= object.Type():
object = object.retrieveLanguageContent()

+ if not
context.isObjectForCurrentLanguage(object):
+ continue
+
object_metatype = object.getTypeInfo().Metatype()
object_state =
portal_workflow.getInfoFor(object, 'review_state', None)

@@ -53,3 +61,4 @@
siteMap.sort(lambda
a,b:cmp(a[0].title_or_id().lower(),
b[0].title_or_id().lower()))
return siteMap

---------------------------------------------------------------------------------------------------------------

## Script (Python) "isObjectForCurrentLanguage"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=object=None
##title=
##
# INFO: This script checks if the current or requested
# object matches the selected language. If you have
# translated a folder then you have the canonical
# version and a translated one. This script returns true
# for the version that matches the selected language
# It also returns True if there is NO translation

object = object or context
portal = context.portal_url.getPortalObject()
if
portal.portal_quickinstaller.isProductInstalled('LinguaPlone'):
if hasattr(object, 'isCanonical'):
transe = object.getTranslation()
if transe:
if transe.absolute_url() ==
object.absolute_url():
return True
else: return False

else: return True

else: return True
else: return True

Discussion

  • Simon Pamies

    Simon Pamies - 2005-05-11
    • status: open --> open-works-for-me
     
  • Simon Pamies

    Simon Pamies - 2005-05-11
    • priority: 5 --> 3
     
  • Encolpe DEGOUTE

    Encolpe DEGOUTE - 2006-05-24
    • status: open-works-for-me --> closed-works-for-me
     

Log in to post a comment.