将globalnav移动到页脚的最简单方法是什么,只在首页上

acl*_*ark 5 plone

我通过以下方式隐藏了普通Plone首页的各种元素:

.section-front-page #portal-globalnav {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

现在,我想在页脚附近的底部添加一个globalnav.我考虑过各种方法:

  • 通过"显示"菜单选择的浏览器视图/模板
  • 另一个观点
  • Javascript(好吧我没有考虑过这个,因为我不太了解Javascript,但似乎有可能.)

什么是最好的方法?

Dav*_*ick 7

在Plone 4及更高版本中,您可以将globalnav viewlet注册为内容提供者:

<adapter
    name="globalnav"
    for="*
         zope.publisher.interfaces.browser.IDefaultBrowserLayer
         *"
    factory="plone.app.layout.viewlets.common.GlobalSectionsViewlet"
    provides="zope.contentprovider.interfaces.IContentProvider"
    />
Run Code Online (Sandbox Code Playgroud)

然后使用以下命令将其包含在主页模板或main_template中:

<tal:block tal:replace="structure provider:globalnav"/>
Run Code Online (Sandbox Code Playgroud)


acl*_*ark 2

我喜欢这两个建议,但最终我做了以下事情(因为我不知道如何用其他建议做我想做的一切):

<browser:viewlet
        name="trueblade.phoenix.footer2"
        manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
        class=".footer2.MyGlobalSectionsViewlet"
        template="footer2.pt"
        permission="zope2.View"
        />
Run Code Online (Sandbox Code Playgroud)

像这样的 footer2.py (子类化而不是其他):

from plone.app.layout.viewlets.common import GlobalSectionsViewlet

class MyGlobalSectionsViewlet(GlobalSectionsViewlet):
    pass
Run Code Online (Sandbox Code Playgroud)

footer2.pt 像这样(除了 CSS id 之外,一切都一样):

<tal:sections tal:define="portal_tabs view/portal_tabs"
 tal:condition="portal_tabs"
 i18n:domain="plone">
<h5 class="hiddenStructure" i18n:translate="heading_sections">Sections</h5>

<ul id="footer2"
    tal:define="selected_tab python:view.selected_portal_tab"
    ><tal:tabs tal:repeat="tab portal_tabs"
    ><li tal:define="tid tab/id"
         tal:attributes="id string:portaltab-${tid};
                        class python:selected_tab==tid and 'selected' or 'plain'"
        ><a href=""
           tal:content="tab/name"
           tal:attributes="href tab/url;
                           title tab/description|nothing;">
        Tab Name
        </a></li></tal:tabs></ul>
</tal:sections>
Run Code Online (Sandbox Code Playgroud)

CSS 如下(仅在首页显示 footer2):

#footer2 {
    display: none;
}

.section-front-page #footer2 {
    display: block;
    margin: 1em;
}
Run Code Online (Sandbox Code Playgroud)

当然,还有 footer2 默认页脚样式的副本:

#footer2 {
    clear: both;
    font-size: 80%;
    background: #ddd;
    /* ensure top navigation dont touches portlets, content etc.. #10491 */
    margin: 0 0 1em 0;
    text-align: center;
}
#footer2 li {
}
#footer2 li a {
    display: inline-block;
    padding: 0.5em 1em 2em 1em;
    background: #ddd;
    min-width: 6em;
    white-space: normal;
    /*TODO: Once we have removed the whitespace from the nav template, this can be put back*/
    /*border-bottom: 0.1em solid White;*/
    border-right: 0.1em solid white;
}

#footer2 .selected a,
#footer2 a:hover {
    background: #205c90;
    color: White;
}
#footer2 .selected a:hover {
    background: #ddd;
    color: #205c90;
}
Run Code Online (Sandbox Code Playgroud)