[Plone-Users] rendering a template dynamically

0 views
Skip to first unread message

anuj maurice

unread,
Dec 31, 2009, 3:09:18 AM12/31/09
to plone...@lists.sourceforge.net
Hi,

My site shows a list of 10 users(genereated via pt file) and when the user clicks "more button" I need to fetch and show next list of  10 users using kss.
refresh viewlet cant be used since it will refresh the list of users already loaded. I could use "insertHtmlAfter" with kss.

how can i render a template(pt file) such that i can transfer the rendered output(html) via kss to the browser and append to the already shown list of users

Am I in the right programing practice with KSS and zpt, else please suggest the right way. Any hints will be really helpful.


Thanks,


The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.

robert rottermann

unread,
Dec 31, 2009, 4:36:29 AM12/31/09
to plone...@lists.sourceforge.net
Am 31.12.2009 09:09, schrieb anuj maurice:
> Hi,
>
> My site shows a list of 10 users(genereated via pt file) and when the
> user clicks "more button" I need to fetch and show next list of 10
> users using kss.
> refresh viewlet cant be used since it will refresh the list of users
> already loaded. I could use "insertHtmlAfter" with kss.
>
> how can i render a template(pt file) such that i can transfer the
> rendered output(html) via kss to the browser and append to the already
> shown list of users
>
create a "container", and then allways fill it with the whole list by using
replaceInnerHTML

robert

here an action I use

@kssaction
def doctorSearchFillbody(self):
ksscore = self.getCommandSet('core')
html = self.template()
tinfo = """
<div id="praxis_list_body" name="praxis_list_body">
<table with="100%%">
<tr>
<th width="100" />
<th width="150" />
<th width="65" />
<th />
</tr>
%s
</table>
</div>
"""
if isIE(self.request):
ksscore.replaceHTML('#praxis_list_body', tinfo % html.strip())
else:
ksscore.replaceInnerHTML('#praxis_list_body', html.strip())

and this is the template that is used (the important thing is
view.getDoctorsList() which return a list of records you want to display)

<table width="100%" border="0" cellspacing="0" cellpadding="3"
style="margin-bottom: 10px">
<tr>
<th width="80" />
<th width="200" />
<th width="30" />
<th />
</tr>
<form id="doctors_edit" name="doctors_edit" >
<tal:block repeat="person python:view.getDoctorsList()">
<tal:block define="surgery python:person.companies and
person.companies[0] or ''">
<tal:block condition="surgery">
<tr tal:define="
mayedit python:person.mayedit;
oddrow repeat/person/odd;
name python:'%s %s %s %s' % (person.greeting,
person.academic_title, person.firstname, person.lastname)"
tal:attributes="class python:oddrow and 'even' or 'odd'">
<td colspan="3" tal:define="cid python:person.id"
width="310" valign="top">
<!-- name: -->
<a tal:attributes="href name;
onClick
python:'set_hidden_value_and_hide_previous_form(\'%s\', \'doctor\')' % cid;"
tal:content="name"
class="doctor_show_edit_container" />
<span tal:condition="not:mayedit" tal:content="name" />
<br>
</td>
<td valign="top">
<!-- Adresse: -->
<span tal:content="python:surgery and
surgery.address" />
<span tal:content="python:' / ' + (person and
surgery.zip or '')" />
<span tal:content="python:surgery and surgery.city"
/><br>
<b>Tel: </b><span tal:content="python:surgery and
surgery.phone" /><br>
</td>
</tr>
<tal:block define="oddrow repeat/person/odd">
<tr tal:attributes="class python:oddrow and 'even' or
'odd'">
<tal:block define="n
python:'doctor_edit_container_%s' % person.id">
<td colspan="5">
<div tal:attributes="name n;id n"></div>
</td>
</tal:block>
</tr>
</tal:block>
</tal:block>
</tal:block>
</tal:block>
</form>
</table>


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Plone-Users mailing list
Plone...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plone-users

i00

unread,
Dec 31, 2009, 1:54:47 PM12/31/09
to plone...@lists.sourceforge.net
Hi Robert,

Thanks a lot. I have used your idea and is planning to generate the HTML
from the template file

Thanks,

Reply all
Reply to author
Forward
0 new messages