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 - - Miroslav Gojic - - On Sun, Oct 9, 2011 at 13:22, Anthony <abasta...@gmail.com> wrote: > On Sunday, October 9, 2011 1:56:18 AM UTC-4, miroslavgojic wrote: >> >> What if I need more than one menu. >> >> Usually I have 2 or 3 menus (top, bottom, and side) >> >> Can I do someting like this: >> in controller >> var1 = (response <http://web2py.com/book/default/docstring/response>.menu >> =(...)) >> var2 = (response <http://web2py.com/book/default/docstring/response>.menu >> =(...)) > > > No, that won't work (not correct Python). But you don't have to use > response.menu at all -- it's just a convenience. MENU() takes any list of > tuples, so you could do: > > menu1 = [...] > menu2 = [...] > > Note, in that case, you would have to define menu1 and menu2 in a model > file (which is where response.menu is often set anyway) so they will be > available in all controllers and views. Alternatively, you could make > response.menu either a list or dictionary of menus: > > response.menu = {} > response.menu['menu1'] = [...] > response.menu['menu2'] = [...] > > and then call MENU(response.menu['menu1']), etc. > > Anthony > > > > >> >> >> in layout >> {{=MENU(var1,_class='sf-menu')**}} >> {{=MENU(var2,_class='sf-menu')**}} >> >> >> - - Miroslav Gojic - - >> >> >> >> On Fri, Oct 7, 2011 at 22:07, Anthony <abas...@gmail.com> wrote: >> >>> See >>> http://web2py.com/book/**default/chapter/05#Custom-**Helpers<http://web2py.com/book/default/chapter/05#Custom-Helpers>for >>> details on using the MENU helper. You can see an example of using it in >>> conjunction with Superfish (which is a Javascript library that turns the >>> list structure generated by MENU into a dynamic menu) in the 'welcome' app: >>> http://code.google.com/p/**web2py/source/browse/** >>> applications/welcome/views/**layout.html#102<http://code.google.com/p/web2py/source/browse/applications/welcome/views/layout.html#102> >>> >>> Anthony >>> >>> >>> On Friday, October 7, 2011 3:08:37 PM UTC-4, miroslavgojic wrote: >>> >>>> this is my controller >>>> >>>> from gluon.tools import Crud >>>> crud = Crud(db) >>>> >>>> def index(): >>>> form=SQLFORM(db.poruke,fields=****['poruka','post_author']) >>>> if form.accepts(request.vars,**sess**ion): >>>> session.flash="new post accepted!" >>>> redirect(URL(r=request)) >>>> poruke=db().select(db.poruke.**A**LL) >>>> return dict(form=form,poruke=poruke) >>>> >>>> def people(): >>>> crud.settings.formstyle = ('divs') >>>> form = crud.create(db.person,next=**URL**('people'),message=T("**record >>>> created")) >>>> persons = crud.select(db.person,fields=[****'name'],headers={'name': >>>> 'Name'}) >>>> return dict(form = form,persons=persons) >>>> >>>> def user(): >>>> auth.settings.formstyle = ('divs') >>>> return dict(form=auth()) >>>> >>>> this is my layout >>>> >>>> <!DOCTYPE html> >>>> <html> >>>> <head> >>>> <title>Web2Py</title> >>>> </head> >>>> <body> >>>> {{try:}}{{=auth.navbar(action=****URL('default','user'))}}{{**exce* >>>> *pt:pass}}<br /> >>>> {{include}} >>>> >>>> <div class="sidebar"> >>>> {{block mysidebar}} >>>> default sidebar >>>> {{end}} >>>> </div> >>>> >>>> <div class="ez-box" id="footer"> >>>> {{=T('Copyright')}} © 2010 - >>>> {{=T('Powered by')}} <a href="http://www.web2py.com">**w** >>>> eb2py</a> >>>> </div> >>>> </body> >>>> </html> >>>> >>>> this is my view >>>> >>>> {{extend 'layout.html'}} >>>> >>>> {{for poruke in poruke:}} >>>> {{if poruke.post_author:}} >>>> {{=poruke.post_author}} says {{=poruke.poruka}} <br /> >>>> {{else:}} >>>> Anonymous says {{=poruke.poruka}}<br /> >>>> {{pass}} >>>> {{pass}} >>>> >>>> {{=form}} >>>> >>>> {{include 'test.html'}} >>>> >>>> {{block mysidebar}} >>>> my block >>>> {{end}} >>>> >>>> How t make implementation of >>>> >>>> response <http://web2py.com/book/default/docstring/response>.menu = >>>> [('Google', False, 'http://www.google.com',[]), >>>> >>>> >>>> >>>> ('Index', True, URL >>>> <http://web2py.com/book/default/docstring/URL>('index'), [])] >>>> >>>> * >>>> * >>>> >>>> >>>> >>>> - - Miroslav Gojic - - >>>> >>>> >>>> >>>> On Fri, Oct 7, 2011 at 18:58, Anthony <aba...@gmail.com> wrote: >>>> >>>>> On Friday, October 7, 2011 1:31:08 AM UTC-4, miroslavgojic wrote: >>>>>> >>>>>> Thanks for blocks - that work, this is similar to modules in joomla, I >>>>>> can write small block and get content on specific place at layout. >>>>>> >>>>>> I tray to use next code: >>>>>> >>>>>> response <http://web2py.com/book/default/docstring/response>.menu = >>>>>> [('Google', False, 'http://www.google.com',[]), >>>>>> >>>>>> >>>>>> >>>>>> ('Index', True, URL >>>>>> <http://web2py.com/book/default/docstring/URL>('index'), [])] >>>>>> >>>>>> but without any success. >>>>>> I reed in book that mentioned code I must put in controller but how to >>>>>> get same than in layout and does in controller I must use definition or >>>>>> haw. >>>>>> >>>>> >>>>> Can you show the relevant controller and view code related to the menu? >>>>> What do you expect to see, and what do you actually see? Note, typically >>>>> you >>>>> would pass response.menu to the MENU() helper, which will turn it into a >>>>> nested unordered list, which can then be styled/displayed as a menu via >>>>> CSS >>>>> and/or Javascript (e.g., the 'welcome' app uses the Superfish Javascript >>>>> menu). >>>>> >>>>> Anthony >>>>> >>>>> >>>> >>