ビューレットのカスタマイズ [Plone4.0]

ビューレットを変更して、みかけ上の表示などを変更する。

ビューレットの変更

bylineを表示しない

URL/@@manage-viewlets にアクセスして plone.belowcontenttitle.documentbyline を隠す。

プロダクトに組み込むには profiles/default/viewlets.xml に次のように追記する。

<hidden manager="plone.belowcontenttitle" skinname="My Theme">
<viewlet name="plone.belowcontenttitle.documentbyline"/>
</hidden>

colophonを表示しない

URL/@@manage-viewlets にアクセスして plone.colophon を隠す。

プロダクトに組み込むには profiles/default/viewlets.xml に次のように追記する。

<hidden manager="plone.portalfooter" skinname="My Theme">
<viewlet name="plone.colophon"/>
</hidden>

ページ下部のカテゴリを表示しない

URL/@@manage-viewlets にアクセスして plone.belowcontenttitle.keywords を隠す。

プロダクトに組み込むには profiles/default/viewlets.xml に次のように追記する。

<hidden manager="plone.belowcontent" skinname="My Theme">
<viewlet name="plone.belowcontenttitle.keywords"/>
</hidden>

パーソナルバーを表示しない

URL/@@manage-viewlets にアクセスして plone.personal_bar を隠す。

プロダクトに組み込むには profiles/default/viewlets.xml に次のように追記する。

<hidden manager="plone.portalheader" skinname="My Theme">
<viewlet name="plone.personal_bar"/>
</hidden>

フッタのサイトアクションを表示しない

URL/@@manage-viewlets にアクセスして plone.site_actions を隠す。

プロダクトに組み込むには profiles/default/viewlets.xml に次のように追記する。

<hidden manager="plone.portalfooter" skinname="My Theme">
<viewlet name="plone.site_actions"/>
</hidden>

ヘッダにサイトアクションビューレットを追加

<browser:viewlet
    name="plone.site_actions"
    layer=".interfaces.IThemeSpecific"
    manager="plone.app.layout.viewlets.interfaces.IPortalHeader"
    class="plone.app.layout.viewlets.common.SiteActionsViewlet"
    permission="zope2.View"
    />

ヘッダのビューレットの並べ替え

URL/@@manage-viewlets にアクセスすれば手動で並べ替えることができる。

プロダクトに組み込むには profiles/default/viewlets.xml に次のように追記する。

<order manager="plone.portalheader" skinname="My Theme">
<viewlet name="plone.skip_links"/>
<viewlet name="plone.personal_bar"/>
<viewlet name="plone.app.i18n.locales.languageselector"/>
<viewlet name="plone.searchbox"/>
<viewlet name="plone.site_actions"/>
<viewlet name="plone.logo"/>
<viewlet name="plone.global_sections"/>
</order>

パンくずに「ホーム→」を表示しない

portal_view_customizations で plone.path_bar を編集する。

- <span id="breadcrumbs-you-are-here" i18n:translate="you_are_here">You
are here:</span>
- <span id="breadcrumbs-home">
-     <a i18n:translate="tabs_home"
-        tal:attributes="href view/navigation_root_url">Home</a>
-     <span tal:condition="breadcrumbs" class="breadcrumbSeparator">
-         <tal:ltr condition="not: is_rtl">&rsaquo;</tal:ltr>
-         <tal:rtl condition="is_rtl">&lsaquo;</tal:rtl>
-     </span>
- </span>

Bylineに作成者へのリンクを表示しない

portal_view_customizations で plone.belowcontenttitle.documentbyline を編集する。

- <a href="#"
-    tal:attributes="href string:${context/@@plone_portal_state/navigation_root_url}/author/${creator_id}"
-    tal:content="view/authorname"
-    tal:omit-tag="python:view.author() is None"
-    i18n:name="author">Roland Barthes</a>
+ <span
+    tal:content="view/authorname"
+    tal:omit-tag="python:view.author() is None"
+    i18n:name="author">Roland Barthes</span>

履歴に作成者へのリンクを表示しない

portal_view_customizations で contenthistory を編集する。

- <a href=""
+ <span
-    tal:condition="actor_home"
-    tal:attributes="href actor_home"
-    tal:content="actor_name"> runyaga </a>
+    tal:content="actor_name"> runyaga </span>

グローバルナビを変更する

portal_view_customizations で plone.global_sections を編集する。

フッターの変更

ZMI の plone で portal_view_customizations を選択し、plone.footer を編集すれば良い。

<div metal:define-macro="portal_footer"
     i18n:domain="plone"
     class="row">
    <div class="position-0 width-full cell">
        <div id="portal-footer">
            <div class="footer-name">
              (c) Kyoto University, Graduate School of Engineering. All Rights Reserved.
            </div>
        </div>
    </div>
</div>

プロダクトに組み込むには browser ディレクトリに footer.pt として上記の変更を加えたテンプレートを格納し、configure.zcml ファイルを次のように編集すれば良い。

+ <browser:viewlet
+ name="plone.footer"
+ manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
+ template="footer.pt"
+ permission="zope.Public"
+ />

共有(@@sharing)ページの変更

プロダクトの browser ディレクトリに sharing.pt, sharing.py, kss_sharing.py, macro_wrapper.pt を作成する。デフォルトのものは plone.app.workflow プロダクトの browser ディレクトリにあるので、これを変更する形でカスタマイズすると良い。例えば次の点を修正する。

  • 共有ページに「上位レベルからパーミッションを引き継ぐ」を表示しない
    sharing.pt を編集する。
- <div class="field">
+ <div class="field" style="display:none;">
      <input class="noborder"
             type="checkbox"
             name="inherit:boolean"
  • 共有ページにユーザIDを表示しない
    sharing.pt を編集する。
- <tal:title condition="python:entry['title']!=entry['id']">
+ <tal:title condition="nothing">
  • ログインしたユーザを表示しない
    sharing.pt を編集する。
- tal:attributes="class python:oddrow and 'odd' or 'even'">
+ tal:attributes="class python:oddrow and 'odd' or 'even'"
+ tal:condition="python:entry['id']!='AuthenticatedUsers'">

browser ディレクトリの configure.zcml ファイルを次のように編集する。

+ <browser:page
+ name="sharing"
+ for="*"
+ layer=".interfaces.IThemeSpecific"
+ class=".sharing.SharingView"
+ permission="plone.DelegateRoles"
+ />
+
+ <browser:page
+ for="*"
+ layer=".interfaces.IThemeSpecific"
+ class=".kss_sharing.KSSSharingView"
+ name="updateSharingInfo"
+ attribute="updateSharingInfo"
+ permission="plone.DelegateRoles"
+ />

検索ボックスの変更

ZMI の plone で portal_view_customizations を選択し、plone.searchbox を編集する。

  • 「現在のセクション内のみ」を表示しない
- <div class="searchSection">
+ <div class="searchSection" tal:condition="nothing">
  • title属性「サイトを検索」を表示しない
- title="Search Site"
  accesskey="4"
- i18n:attributes="title title_search_site;"
   :
- class="inputLabel searchField" />
+ class="inputLabel" /> 

これを設定プロダクトで行うには、プロダクトの browser ディレクトリに searchbox.pt を作成し上記の変更を行う。デフォルトのものは plone.app.layout プロダクトの viewlets ディレクトリにあるので、これを変更する形でカスタマイズすると良い。

次にbrowser ディレクトリの configure.zcml ファイルを次のように編集する。

+ <!-- 検索ボックス -->
+ <browser:viewlet
+ name="plone.searchbox"
+ for="*"
+ class="plone.app.layout.viewlets.common.SearchBoxViewlet"
+ permission="zope2.View"
+ template="searchbox.pt"
+ manager="plone.app.layout.viewlets.interfaces.IPortalHeader"
+ />

タイトルバーの日英対応

日本語・英語でタイトルを変更する設定を行う。なお事前に日本語タイトルは、Plone ルートの Properties タブで title_ja として追加されているものとする。ZMI の portal_view_customizations で plone.htmlhead.title を編集する。

<title tal:define="portal python:context.portal_url.getPortalObject();
site_title portal/title | nothing;
site_title_ja portal/title_ja | nothing;
site_title_disp python:(context.Language()=='ja' and site_title_ja) and site_title_ja or site_title;
page_title context/Title;"
tal:content="structure python:str(page_title)+' - '+str(site_title_disp)">Site Title</title>

これを設定プロダクトで行うには、プロダクトの browser ディレクトリに title.pt を作成し上記の変更を行う。デフォルトのものは plone.app.layout プロダクトの viewlets ディレクトリにあるので、これを変更する形でカスタマイズすると良い。

次にbrowser ディレクトリの configure.zcml ファイルを次のように編集する。

+ <!-- タイトルバー -->
+ <browser:viewlet
+ name="plone.htmlhead.title"
+ for="*"
+ manager="plone.app.layout.viewlets.interfaces.IHtmlHead"
+ class="plone.app.layout.viewlets.common.TitleViewlet"
+ template="title.pt"
+ permission="zope2.View"
+ />