On Monday, October 24, 2011 1:30:23 PM UTC-4, annet wrote:
>
> Would it be possible to have the business card function with its 
> corresponding view, and a separate function that initially gets the 
> image and text and when the visitor clicks the timetable link, a 
> function that gets the timetable and a link to the image and text bit 
> to return to the business card.
>

You might consider doing this with Ajax 
components: http://web2py.com/book/default/chapter/13#Components

In the view, where you want the initial image and text, do:

{{=LOAD('default', 'get_text.load', args=company.id, ajax=True, 
target='content')}}

This assumes a get_text() function in the default controller, and a 
/default/get_text.load view (you could also just use a get_text.html view, 
but using a .load view enables you to have a separate .html view if needed 
-- and the .load extension will propogate to any links clicked within the 
component as well). Then for the link to switch the content of that 
component div:

{{=A('show timetable', _href=URL('timetable', 'timetable.load', 
args=company.id), cid='content')}}

When the link is clicked, it will call the timetable component and put the 
result in the 'content' div (cid stands for "component id", which is the div 
the original component was loaded into).
 

>
>   ## this bit should be replaced with the timetable 
>   {{if image:}} 
>     <div id="banner" style="text-align:center; height: 120px;"> 
>       ... 
>     </div> <!-- banner --> 
>   {{pass}} 
>   {{if text:}} 
>     <div class="oneColLayout"> 
>       ... 
>     </div> <!-- oneColLayout --> 
>   {{pass}} 
>   ## ends here. 
>
>   ## here the link to the timetable (and later to the business card) 
>   <div id= "footer"> 
>   
> {{=A('Lesrooster',_href=URL('timetable','timetable',args=[company.id]))}} 
>
 
It might be easier to go with the component method mentioned above, but you 
could achieve something similar with:

<div id="content">
[initial image and text go here -- using your code from above]
</div>

{{=A('Lesrooster', callback=URL('timetable', 'timetable', args=company.id), 
target='content')}}

I think this method just uses the ajax() function, not the more 
sophisticated web2py_component() function that is used for components. See 
details about the A() helper 
here: http://web2py.com/book/default/chapter/05#Built-in-Helpers.

Anthony

Reply via email to