On Wednesday, March 2, 2011 8:41:48 AM UTC-5, stargate wrote: 
>
> I am looking at the following example here located 
>
> http://web2py.com/AlterEgo/default/show/106 
>
>
> If you go to the heading 
>
> PHP files and web2py views 
>
> Further down there is a web2py example.  Now i create a controller 
> called loop and a html page called loop but how do i call the 
> controller in the loop.html page.

 
You don't have to call the controller from the loop.html page. Even though 
the URL is /[app]/[controller]/loop.html, web2py does not start with the 
execution of loop.html and then call the 'loop' controller from there. 
Rather, the order is reversed -- web2py executes the 'loop' controller and 
then passes its returned value (which is a dictionary of values) to 
loop.html, which is then rendered by the templating engine. On the AlterEgo 
page you are referencing, the second paragraph of the introduction explains 
this.
 
For more details, see http://web2py.com/book/default/chapter/03#Say-Hello and 
http://web2py.com/book/default/chapter/04#Dispatching.
 
Note, by default, when a given controller action is executed (e.g., 'loop'), 
web2py looks for a view with the same name (e.g., loop.html). However, you 
can explicitly tell web2py to call a different view by setting response.view 
to a different view. You can also call response.render explicitly in the 
contoller and return the complete rendered HTML instead of a dictionary of 
values (in that case, the HTML is returned directly). You don't usually need 
to do this. For details see 
http://web2py.com/book/default/chapter/04?search=response.view#response.
 
Anthony
 
 
 
 
 

Reply via email to