This is much better ... just how to define condition only for index page (or function or controller)
{{if condition:}} how to make definition of condition - there no need to be request.url it can be request.controller when I tray this I get an error: {{if {{=request.function}} == index:}} your html goes here {{else:}} alternative html goes here {{pass}} But this is work {{if request.function == 'index':}} your html goes here {{else:}} alternative html goes here {{pass}} Thanks - - Miroslav Gojic - - On Mon, Oct 10, 2011 at 22:53, Anthony <abasta...@gmail.com> wrote: > On Monday, October 10, 2011 4:03:49 PM UTC-4, miroslavgojic wrote: >> >> with >> {{=request.url}} >> i will get >> /some/my/url/address >> >> but when I tray next example it is not working: >> >> {{ >> myurl = request.url: >> i = /some/my/url/address: >> if i == myurl: >> response.writ('my first HTML output') >> else: >> response.write('my other HTML output') >> pass >> }} >> >> how to resolve this, I need one part layout.htm to be different for index >> page than an other pages, is there some other solutions >> > > How about using a block: > http://web2py.com/book/default/chapter/05#Blocks-in-Views? Define the > default content of the block in layout.html, and define the index specific > content in index.html. > > A few other points: > > - I believe request.url will contain the rewritten version of the > requested URL if you're using routes.py, so it may not match your > hand-coded > URL. > - If you need to determine the current function (and/or controller), > it's better to match request.function (and/or request.controller) rather > than trying to match the full URL (which could get tricky if the are args, > a > query string, or any rewrites going on). > - Using response.write is generally discouraged and usually unnecessary > -- instead, just do: > > {{if condition:}} > your html goes here > {{else:}} > alternative html goes here > {{pass}} > > Anthony > >