Random stuff on frontpage

Espen Moe-Nilssen espen at medialog.no
Mon Nov 12 17:02:00 UTC 2007


I made a template to show a random photo on the front page.
As far as I understand, it is easy to use the same approach to show  
other random stuff (like a changing front-page in a "store", for  
example by setting the path to a smartfolder and using a macro to  
display a page.

Thought I should tell, as this might be handy for some (?)

Here is the code (you can see the results at: http://xweb11.plana.dk: 
8092/brunII ) (saved the template as front-page)

__________________________________________________________________

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no" lang="no"
       metal:use-macro="here/main_template/macros/master"   
18n:domain="plone">

<body>

<div metal:fill-slot="main">
<h1>Fotograf Hans Jørgen Brun</h1>
<p class="documentDescription">Norges mest premierte fotograf</p>

             <div tal:define="presults python:container.portal_catalog 
(Type='Image',
                          review_state=['published','visible'],
                          path='/brunII/barn/')"
              tal:condition="presults"
              tal:on-error="nothing" >


             <tal:block tal:define="pobj python:random.choice 
(presults).getObject()">

              <img tal:attributes="src string:${pobj/absolute_url}/ 
image" alt="" />

             </tal:block>
           </div>
         </div>

</body>
</html>

_________________________________________________________________

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20071112/9e43ec83/attachment-0001.html>


More information about the Product-Developers mailing list