Bookmark and Share
Document Actions

Creare un menù di navigazione "orizzontale"
medio

Come creare un portlet di navigazione che mostri i contenuti di una singola cartella, e non l'intera gerarchia del sito, in modo da renderlo più agile.

L'intero albero di navigazione può diventare un po' troppo complicato e profondo man mano che si naviga in un sito internet. Per mitigare questa situazione, si può creare un portlet che mostri solo i contenuti di una certa cartella, rispettando le impostazioni di navigazione che si trovano nel pannello di controllo di Plone.

Aggiungere i seguenti elementi in portal skins->cartella personalizzata del proprio sito:

Page Template: portlet_localnav:

<html xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      i18n:domain="plone">
<body>
<div metal:define-macro="portlet"
       i18n:domain="plone"
       tal:omit-tag="">
<dl class="portlet" id="portlet-localnav-tree">
<dt class="portletHeader">Navigation</dt>
<dd tal:define="navData here/getLocalNav;
                contents python:navData['Contents'];
                folder python:navData['Folder'];
                normalizeString python:here.plone_utils.normalizeString;
                hereURLs python:[here.absolute_url(), here.getParentNode().absolute_url()]"
    class="portletItem">
  <div tal:define="url folder/absolute_url">
    <a tal:attributes="class python:test(here.absolute_url() in hereURLs or
folder.getDefaultPage() == here.id, 'selected ','') +
'localnavRootItem visualIconPadding contenttype-' +
normalizeString(folder.portal_type);
                       href url"
       tal:content="folder/Title"
       href="#">
      Title
    </a>
  </div>
  <tal:block repeat="item contents">
    <div tal:define="url python:test(item.portal_type == 'Link', item.getRemoteUrl, item.getURL())">
      <a tal:attributes="class python:test(url in hereURLs, 'selected ','') +
'localnavItem visualIconPadding contenttype-' +
normalizeString(item.portal_type);
                         href url"
         tal:content="item/Title"
         href="#">
        Title
      </a>
    </div>
  </tal:block>
</dd>
</dl>
</div>
</body>
</html>

Script (Python): getLocalNav (senza parametri)

ct = context.portal_catalog
ntp = context.portal_properties.navtree_properties
wft = context.portal_workflow
putils = context.plone_utils
types_to_list = putils.typesToList()
portalObject = context.portal_url.getPortalObject()




query = {}
query['portal_type'] = types_to_list
query['is_default_page'] = False
query['sort_on'] = 'getObjPositionInParent'
if ntp.getProperty('enable_wf_state_filtering', False):
        query['review_state'] = ntp.wf_states_to_show
contents = []
folder = context
while 1:
        query['path'] = {
                'query':        '/'.join(folder.getPhysicalPath()),
                'depth':        1,
        }
        contents = ct(**query)
        if len(contents) > 0 or folder == portalObject:
                return {'Folder':folder, 'Contents':contents}
        else:
                folder = folder.getParentNode()

Ora, aggiungere nei left_slots o right_slots sotto le proprietà di ZMI in qualsiasi cartella scelta del proprio sito Plone (o il sito stesso):

here/portlet_localnav/macros/portlet

Si dovranno anche definire gli stili per le classi usate nella creazione del portlet.

 
by Alice Narduzzo last modified 2008-10-21 15:41