Sto modificando questo codice di weblion
https://weblion.psu.edu/trac/weblion/wiki/RandomImagePortlet (usato per
mostrare in un portlet una immagina casuale) in modo che mostri il contenuto
di una news casuale.


<div metal:define-macro="portlet">
     <div  id="portlet_randomphoto"
             tal:define="presults
python:context.portal_catalog(portal_type='Image',
                         path='/yaks/images-randomize')"
             tal:condition="presults">
             <div>

               <span tal:define="pobj
python:random.choice(presults).getObject()">
                     <img tal:replace="structure pobj/image" />
                     <span
tal:content="string:${pobj/Description}">[displays description of
image]</span>
               </span>
          </div>
     </div>
</div>



Sto provando con questo codice

<div metal:define-macro="portlet">
     <div  id="portlet_randomphoto"
             tal:define="presults
python:context.portal_catalog(portal_type='News Item',
                         path='/test/news')"
             tal:condition="presults">
             <div>

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

                     <span
tal:content="string:${pobj/Description}">[displays description of
image]</span>
                   <div tal:replace="structure pobj/SearchableText">This
element is a comment.</div>
               </span>
          </div>
     </div>
</div>

Ma non riesco ad estrarre il testo della news in modo decente.
Con SearchableText, infatti,  il testo viene fuori come non formattato e si
prende pure la descrizione della immagine a commento della news.
Forse che il testo della news non viene estratto con getObject()?
C'รจ qualche altro modo di ottenerlo?

a presto

faber

--------------------
"Life is what happens to you while you're busy making other plans" - J.
Lennon
_______________________________________________
Plone-IT mailing list
Plone-IT@lists.plone.org
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html

Reply via email to