How to make a gallery view for a page

by Espen Moe-Nilssen last modified May 27, 2011 10:32 AM
This how to describes how to make a view for a page so the page also shows a gallery. For example if you want a "news-item view" kind of look for a page, but with a gallery instead of an image.

1) Add a folder with some images

2) Make it a gallery - set the width, hight etc.

3) Customize the document view (its in http://yoursite/portal_skins/plone_content ), rename it to "gallery_document_view" and add these lines (before the title part, maybe)

_______________

<tal:block tal:define="parent nocall:context/aq_parent"  tal:on-error="nothing">

<tal:block tal:define="parent nocall:here/aq_inner/aq_parent"  tal:on-error="nothing">

<div tal:replace="structure parent/@@placegalleryview">the gallery comes here

</div>

</tal:block>

_______________

Add a page in the folder

Choose the view by

1) going to /portal_types and add it to "Page", this will make it available everywhere

or

2) go to http://mysite/mygalleryfolder/mypage/manage_main and click on the "properties tab" and add a property "layout" and give it the value "gallery_document_view".

______________________

Then you might want to go to the gallery-folder and make the document the default view of that folder"

Layout

CSS can probably be done something like this:

.template-gallery_document_view #plonetruegallery-container {

float:right; margin: 10px;

}

Full code for view for Plone 4:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"

xmlns:tal="http://xml.zope.org/namespaces/tal"

xmlns:metal="http://xml.zope.org/namespaces/metal"

xmlns:i18n="http://xml.zope.org/namespaces/i18n"

lang="en"

metal:use-macro="context/main_template/macros/master"

i18n:domain="plone">

<body>

<metal:content-core fill-slot="content-core">

<tal:block tal:define="parent nocall:context/aq_parent"  tal:on-error="nothing">

<div tal:replace="structure parent/@@placegalleryview">the gallery comes here

</div>

</tal:block>

<metal:content-core define-macro="content-core">

<metal:field use-macro="python:context.widget('text', mode='view')">

Body text

</metal:field>

</metal:content-core>

</metal:content-core>

</body>

</html>