Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the most straightforward way to move the globalnav to the footer, only on the front page

Tags:

plone

I have hidden various elements of the normal Plone front page via:

.section-front-page #portal-globalnav {
    display: none;
}

Now, I want to add a globalnav to the bottom near the footer. I've considered a variety of approaches:

  • A browser view/template selected via the Display menu
  • Another viewlet
  • Javascript (OK I haven't considered this because I don't know Javascript very well, but it seems possible.)

What is the best approach?

like image 892
aclark Avatar asked Sep 02 '11 18:09

aclark


2 Answers

In Plone 4 and greater, you can register the globalnav viewlet as a content provider:

<adapter
    name="globalnav"
    for="*
         zope.publisher.interfaces.browser.IDefaultBrowserLayer
         *"
    factory="plone.app.layout.viewlets.common.GlobalSectionsViewlet"
    provides="zope.contentprovider.interfaces.IContentProvider"
    />

and then include it in your homepage template or main_template using:

<tal:block tal:replace="structure provider:globalnav"/>
like image 159
David Glick Avatar answered Sep 29 '22 01:09

David Glick


The only on the front page bit is the tricky part. You could use your GS profile to mark the front page with a special, one-off interface and then use ZCML to register the plone.global_sections viewlet for the IPortalFooter manager for that context and only that context:

<browser:viewlet
    name="plone.global_sections"
    for="my.special.IFrontPage"
    manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
    class="plone.app.layout.viewlets.common.GlobalSectionsViewlet"
    permission="zope2.View"
    />

You could also use this to then register a dummy, empty plone.global_sections viewlet for IPortalHead instead of using display: none;

<browser:viewlet
    name="plone.global_sections"
    for="my.special.IFrontPage"
    manager="plone.app.layout.viewlets.interfaces.IPortalHeader"
    class="my.special.EmptyViewlet"
    permission="zope2.View"
    />
like image 21
Ross Patterson Avatar answered Sep 28 '22 23:09

Ross Patterson