トップページ表示テンプレートの作成 [Plone3.3]
トップページ表示として、メインビジュアル、フリーエリア3か所、お知らせを表示するテンプレートを作成する。お知らせの表示が「日付+タイトル」の場合の「ENG TOPPAGE TOPIC VIEW」、「日付+本文」の場合の「ENG TOPPAGE BLOG VIEW」を定義する。
ENG TOPPAGE TOPIC VIEW
Topicタイプのビューとして ENG TOPPAGE TOPIC VIEW を定義する
工学研究科のトップページ表示用に、Topicタイプのビューを定義する。スキンフォルダ内にテンプレートを eng_toppage_topic_view として作成する。タイトルは「ENG TOPPAGE TOPIC VIEW」とする。
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" metal:use-macro="here/main_template/macros/master" i18n:domain="plone"> <body> <div metal:fill-slot="main"> <metal:main_macro define-macro="main"> <metal:body define-macro="body_macro" tal:define="kssClassesView context/@@kss_field_decorator_view; getKssClasses nocall:kssClassesView/getKssClassesInlineEditable; templateId template/getId"> <div class="toppage"> <!--メインビジュアル--> <div class="top_visual" tal:define="id string:mainvisual.jpg; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <img src="mainvisual.jpg" /> </div> <div class="top_area_one"> <!--フリーエリア1--> <div tal:define="id string:freearea1; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <div tal:define="obj python:results[0].getObject(); translation python:obj.getTranslation(); base_url python:obj.absolute_url();" tal:attributes="class id"> <div tal:replace="structure python:here.transformRelatedURLs(translation.CookedBody(stx_level=2), base_url)" /> <div tal:condition="python:context.portal_membership.checkPermission('Modify portal content', obj)" class="edit-link"> <a tal:attributes="href python:base_url+'/edit'" tal:content="python:test(language=='en', 'Edit', '編集')" /> </div> </div> </div> <!--お知らせ--> <div tal:define="b_size python:10;" class="top_news" tal:condition="here/listCriteria | nothing"> <h2 tal:content="python:test(language=='en', 'News', 'お知らせ')" /> <div class="rss"><a tal:attributes="href python:context.absolute_url() + '/RSS'">RSS</a></div> <div metal:use-macro="here/eng_topic_view/macros/listing" /> <div class="allnews"> <a tal:attributes="href string:../news" tal:content="python:test(language=='en', 'More', u'\u904e\u53bb\u4e00\u89a7')" /></div> </div> </div> <div class="top_area_two"> <!--フリーエリア2--> <div tal:define="id string:freearea2; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <div tal:define="obj python:results[0].getObject(); translation python:obj.getTranslation(); base_url python:obj.absolute_url();" tal:attributes="class id"> <div tal:replace="structure python:here.transformRelatedURLs(translation.CookedBody(stx_level=2), base_url)" /> <div tal:condition="python:context.portal_membership.checkPermission('Modify portal content', obj)" class="edit-link"> <a tal:attributes="href python:base_url+'/edit'" tal:content="python:test(language=='en', 'Edit', '編集')" /> </div> </div> </div> </div> <div class="visualClear"><!----></div> <div class="top_area_three"> <!--フリーエリア3--> <div tal:define="id string:freearea3; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <div tal:define="obj python:results[0].getObject(); translation python:obj.getTranslation(); base_url python:obj.absolute_url();" tal:attributes="class id"> <div tal:replace="structure python:here.transformRelatedURLs(translation.CookedBody(stx_level=2), base_url)" /> <div tal:condition="python:context.portal_membership.checkPermission('Modify portal content', obj)" class="edit-link"> <a tal:attributes="href python:base_url+'/edit'" tal:content="python:test(language=='en', 'Edit', '編集')" /> </div> </div> </div> </div> </div> </metal:body> <div tal:replace="structure provider:plone.belowcontentbody" /> </metal:main_macro> </div> </body> </html>
Topicのビューで選択できるものを指定する
フォルダのビューで選択できるものを指定する。上で作成した、eng_toppage_topic_view も設定できるようにする。portal_types/Topic を開き Available view methods に次の行を追加する。
eng_toppage_topic_view
ENG TOPPAGE BLOG VIEW
Topicタイプのビューとして ENG TOPPAGE BLOG VIEW を定義する
工学研究科のトップページ表示用に、Topicタイプのビューを定義する。スキンフォルダ内にテンプレートを eng_toppage_blog_view として作成する。タイトルは「ENG TOPPAGE BLOG VIEW」とする。
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" metal:use-macro="here/main_template/macros/master" i18n:domain="plone"> <body> <div metal:fill-slot="main"> <metal:main_macro define-macro="main"> <metal:body define-macro="body_macro" tal:define="kssClassesView context/@@kss_field_decorator_view; getKssClasses nocall:kssClassesView/getKssClassesInlineEditable; templateId template/getId"> <div class="toppage"> <!--メインビジュアル--> <div class="top_visual" tal:define="id string:mainvisual.jpg; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <img src="mainvisual.jpg" /> </div> <div class="top_area_one"> <!--フリーエリア1--> <div tal:define="id string:freearea1; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <div tal:define="obj python:results[0].getObject(); translation python:obj.getTranslation(); base_url python:obj.absolute_url();" tal:attributes="class id"> <div tal:replace="structure python:here.transformRelatedURLs(translation.CookedBody(stx_level=2), base_url)" /> <div tal:condition="python:context.portal_membership.checkPermission('Modify portal content', obj)" class="edit-link"> <a tal:attributes="href python:base_url+'/edit'" tal:content="python:test(language=='en', 'Edit', '編集')" /> </div> </div> </div> <!--お知らせ--> <div tal:define="b_size python:5;" class="top_news" tal:condition="here/listCriteria | nothing"> <h2 tal:content="python:test(language=='en', 'News', 'お知らせ')" /> <div class="rss"><a tal:attributes="href python:context.absolute_url() + '/RSS'">RSS</a></div> <div metal:use-macro="here/eng_blog_view/macros/listing" /> <div class="allnews"> <a tal:attributes="href string:../news" tal:content="python:test(language=='en', 'More', u'\u904e\u53bb\u4e00\u89a7')" /></div> </div> </div> <div class="top_area_two"> <!--フリーエリア2--> <div tal:define="id string:freearea2; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <div tal:define="obj python:results[0].getObject(); translation python:obj.getTranslation(); base_url python:obj.absolute_url();" tal:attributes="class id"> <div tal:replace="structure python:here.transformRelatedURLs(translation.CookedBody(stx_level=2), base_url)" /> <div tal:condition="python:context.portal_membership.checkPermission('Modify portal content', obj)" class="edit-link"> <a tal:attributes="href python:base_url+'/edit'" tal:content="python:test(language=='en', 'Edit', '編集')" /> </div> </div> </div> </div> <div class="visualClear"><!----></div> <div class="top_area_three"> <!--フリーエリア3--> <div tal:define="id string:freearea3; path python:'/'.join(context.aq_parent.getPhysicalPath()); results python:context.portal_catalog.searchResults( path={'query':path, 'depth':1}, id=id );" tal:condition="results" tal:omit-tag=""> <div tal:define="obj python:results[0].getObject(); translation python:obj.getTranslation(); base_url python:obj.absolute_url();" tal:attributes="class id"> <div tal:replace="structure python:here.transformRelatedURLs(translation.CookedBody(stx_level=2), base_url)" /> <div tal:condition="python:context.portal_membership.checkPermission('Modify portal content', obj)" class="edit-link"> <a tal:attributes="href python:base_url+'/edit'" tal:content="python:test(language=='en', 'Edit', '編集')" /> </div> </div> </div> </div> </div> </metal:body> <div tal:replace="structure provider:plone.belowcontentbody" /> </metal:main_macro> </div> </body> </html>
Topicのビューで選択できるものを指定する
フォルダのビューで選択できるものを指定する。上で作成した、eng_toppage_blog_view も設定できるようにする。portal_types/Topic を開き Available view methods に次の行を追加する。
eng_toppage_blog_view