I tried:
Controller:
def imagetext():
id=request.args(0)
image=db((db.bedrijfimagelink.bedrijf_id==id).select(db.imagelink.link).first()
text=db(db.hptext.bedrijf_id==id).select(db.hptext.tekst).first()
return dict(image=image,text=text)
View:
<div id="component">
{{=LOAD('locator','imagetext.load',args=283,ajax=True,target='component')}}
</div>
and the second view locator/imagetext.load:
{{if image:}}
<div id="banner" style="text-align:center; height: 120px;">
{{=IMG(_src=URL('static','init/images/banners/%s' % image.link),
_width="696px", _height="120px")}}
</div> <!-- banner -->
{{pass}}
{{if text:}}
<div class="oneColLayout">
<div style="margin: 24px 36px 0px 36px">
{{=XML(text.tekst)}}
</div> <!-- box -->
</div> <!-- oneColLayout -->
{{pass}}
But the div displays Loading... instead of the text and the image.
I also tried:
Controller:
def businesscard():
if not len(request.args):
redirect(URL('default','error'))
else:
id=request.args(0)
...
functions=db(db.function.bedrijf_id==id).select(db.function.ALL).first()
...
if functions.image:
image=db((db.bedrijfimagelink.bedrijf_id==id).select(db.imagelink.link).first()
if functions.text:
text=db(db.hptext.bedrijf_id==id).select(db.hptext.tekst).first()
....
return dict(..,image=image,text=text)
View:
<div id="component">
{{if image:}}
<div id="banner" style="text-align:center; height: 120px;">
{{=IMG(_src=URL('static','init/images/banners/%s' % image.link),
_width="696px", _height="120px")}}
</div> <!-- banner -->
{{pass}}
{{if text:}}
<div class="oneColLayout">
<div style="margin: 24px 36px 0px 36px">
{{=XML(text.tekst)}}
</div> <!-- box -->
</div> <!-- oneColLayout -->
{{pass}}
</div> <!-- component -->
...
<div id= "footer">
{{=A('Lesrooster',callback=URL('timetable','timetable',args=[company.id]),target='component')}}
</div> <!-- footer -->
Which generates the following link:
<a onclick="ajax('ini/timetable/timetable/283',[],'component');return
false;"href="#null">Lesrooster</a>
.. and address in the browser:
http://127.0.0.1:8000/init/locator/businesscard/283#null
... but doesn;t work either.
The problem with Cliff's solution (and all the examples at w3c) is
that the image and text are part of the first page, I cannot have the
vistor click a button to display the image and text.
I hope there is a way to get this to work ..
Kind regards,
Annet.