Skip to content

nan

Sections
Personal tools
You are here: Home » How Tos » Portlet to display a random Photo   rndphotoportlet
Log in
No Software Patents!

Under the influence of the patent system and big industry lobbyists, the European Union is on the verge of making a huge mistake: to pass a law that would legalize software patents.

 

Portlet to display a random Photo

Document Actions
This Portlet displays a random Photo. It needs CMFPhoto and CMFPhotoAlbum.

Create a Pagetemplate named portlet_rndphoto in your custom Folder. Place the following code into it:

 <html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
i18n:domain="rndphoto">

<body>

<div metal:define-macro="portlet">

<div class="portlet" id="portlet-rndphoto">

<h5 i18n:translate="box_rndphoto">Random Photo</h5>

<div class="portletBody"
tal:define="presults python:container.portal_catalog(portal_type='Photo',
path='/'.join(here.getPhysicalPath()),
review_state=['published','visible']);" >
<tal:block tal:define="pobj python:random.choice(presults).getObject()">

<div class="portletContent odd">

<a href=""
tal:attributes="href string:${pobj/absolute_url}/view">
<b tal:content=" string:${pobj/title_or_id}" /> <br/>
<img tal:attributes="src string:${pobj/absolute_url}/variant/thumbnail" alt="" />
</a>
</div>
<div class="portletContent even">

<span tal:omit-tag="" i18n:domain="plone" i18n:translate="posted_by">Posted by</span>
<!--tal:attributes="href python:here.portal_membership.getHomeUrl(pobj.Creator) -->
<span class="link-user">
<a href=""
tal:attributes="href python:here.portal_membership.getHomeUrl(pobj.Creator())"
tal:on-error="nothing"
tal:content="string:${pobj/Creator}">
Author
</a>
<span tal:omit-tag="" i18n:domain="plone" i18n:translate="label_published">Published</span>:
<span tal:replace="string:${pobj/Date}" />
</span>

</div>
</tal:block>

</div>
</div>
</div>

</body>
</html>

Goto your Plone root or the folder you want to display the portlet in and add to the right/left_slots property here/portlet_rndphoto/macros/portlet.

This works with CMFPhoto and CMFPhotoalbum, but it can be easily customized to be used with other photoalbum products ;)

Created by nan
Last modified 2004-12-15 05:30 PM
« November 2009 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
 
 

Powered by Plone

This site conforms to the following standards: