Hello,

I have been trying to add external links to the menu system, but they 
result in malformed or invalid URL's when setting the target attribute.
There are some old posts in the group regarding this, but none of the 
suggestions have worked.

Web2py version : 2.16.1-stable

Example:
response.menu += [
    ('External Links', False, '#', [
        ('Icinga', False, URL('icinga'), []),
        # Works
        # SRC: <a class="dropdown-item" 
href="/Rakesh_Singh/default/icinga">Icinga</a>
        ('Google', False, google, []),
        # Works
        # SRC: <a class="dropdown-item" 
href="https://www.google.com";>Google</a>

        # Change target...
        ('', False, A('Icinga', _href=URL('icinga'), _target="_blank"), []),
        # Does not work; Menu item displays "Icinga\n>"
        # SRC: <a class="dropdown-item" href="<a 
href="/Rakesh_Singh/default/icinga" target="_blank">Icinga</a>"></a>        
        ]
    )
]


I have added a 'dirty' workaround in my layout.html that changes the target 
to '_blank' if the URL contains the string 'http'

            <div class="dropdown-menu">
              {{for _subitem in _item[3]:}}
              {{if _subitem[2].__contains__('http'):}}
                {{_target = '_blank'}}
                {{_rel = 'noopener'}}
              {{else:}}
                {{_target = '_self'}}
                {{_rel = 'preconnect '}}
              {{pass}}
              <a class="dropdown-item" href="{{=_subitem[2]}}" 
target="{{=_target}}" rel="{{=_rel}}">{{=_subitem[0]}}</a>


Is there something incorrect in my code when specifying the target?

Thank you.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to