Hello,
I have created 2 links on my homepage and in the menu nav of my application, however I would like those 2 links to open in a new tab, Is that possible?
Thanks in advance,
Wilfredo
Links on homepage and nav bar to open in a new tab
-
- AppGini Super Hero
- Posts: 85
- Joined: 2014-06-14 03:08
- Location: India
- Contact:
Re: Links on homepage and nav bar to open in a new tab
Hi
use target="_blank" to open in new tab.
Example:
use target="_blank" to open in new tab.
Example:
Code: Select all
<a target="_blank" href="http://your_url_here.html">Link</a>
Re: Links on homepage and nav bar to open in a new tab
Thank you for your response Uday,
However the link is in an array:
$navLinks[] = array(
'url' => 'http://my_url.php',
'target' => '_blank',
'title' => 'Print invoices',
'groups' => array('*') // groups allowed to see this link, use '*' if you want to show the link to all groups
);
$navLinks[] = array(
'url' => 'http://my_url.php',
'target' => '_blank',
'title' => 'Go to my webpage',
'groups' => array('*') // groups allowed to see this link, use '*' if you want to show the link to all groups
);
This is in the links-navemenu.php hook.
As you can see, I have added the target in the array, but it is not working.
Wilfredo
However the link is in an array:
$navLinks[] = array(
'url' => 'http://my_url.php',
'target' => '_blank',
'title' => 'Print invoices',
'groups' => array('*') // groups allowed to see this link, use '*' if you want to show the link to all groups
);
$navLinks[] = array(
'url' => 'http://my_url.php',
'target' => '_blank',
'title' => 'Go to my webpage',
'groups' => array('*') // groups allowed to see this link, use '*' if you want to show the link to all groups
);
This is in the links-navemenu.php hook.
As you can see, I have added the target in the array, but it is not working.
Wilfredo
Re: Links on homepage and nav bar to open in a new tab
Hi Wilfredo,
I had the need for the same nav-links behaviour and managed to achieve it by adding the 'target' array to links-navmenu.php and editing the generated lib.php. The following edits don't affect any existing generated navmenu links and you can specifiy whatever 'target' attribute you want for any additional links:
to open a link in a new tab, in links-navmenu.php add the 'target' array, as follows:
then edit lib.php as follows:
find and replace (somewhere around line 102)
with this:
Available 'target' attributes:
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
I hope that helps.
I had the need for the same nav-links behaviour and managed to achieve it by adding the 'target' array to links-navmenu.php and editing the generated lib.php. The following edits don't affect any existing generated navmenu links and you can specifiy whatever 'target' attribute you want for any additional links:
to open a link in a new tab, in links-navmenu.php add the 'target' array, as follows:
Code: Select all
$navLinks[] = array(
'url' => 'path/to/link',
'target' => '_blank',
'title' => 'Link title',
'groups' => array('group1', 'group2'),
'icon' => 'path/to/icon'
);
find and replace (somewhere around line 102)
Code: Select all
// custom nav links, as defined in "hooks/links-navmenu.php"
global $navLinks;
if(is_array($navLinks)){
$memberInfo = getMemberInfo();
$links_added = 0;
foreach($navLinks as $link){
if(!isset($link['url']) || !isset($link['title'])) continue;
if($memberInfo['admin'] || @in_array($memberInfo['group'], $link['groups']) || @in_array('*', $link['groups'])){
if(!$links_added) $menu .= '<li class="divider"></li>';
$menu .= "<li><a href=\"{$link['url']}\"><img src=\"" . ($link['icon'] ? $link['icon'] : 'blank.gif') . "\" height=\"32\"> {$link['title']}</a></li>";
$links_added++;
}
}
}
Code: Select all
// custom nav links, as defined in "hooks/links-navmenu.php"
global $navLinks;
if(is_array($navLinks)){
$memberInfo = getMemberInfo();
$links_added = 0;
foreach($navLinks as $link){
if(!isset($link['url']) || !isset($link['title']) || !isset($link['target'])) continue;
if($memberInfo['admin'] || @in_array($memberInfo['group'], $link['groups']) || @in_array('*', $link['groups'])){
if(!$links_added) $menu .= '<li class="divider"></li>';
$menu .= "<li><a href=\"{$link['url']}\" target=\"{$link['target']}\"><img src=\"" . ($link['icon'] ? $link['icon'] : 'blank.gif') . "\" height=\"32\"> {$link['title']}</a></li>";
$links_added++;
}
}
}
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
I hope that helps.
Re: Links on homepage and nav bar to open in a new tab
I have found a very simple way to achieve this. Jus add this to the URL: " target="blank" in the links-navmenu.php. The code then is like this:
$navLinks[] = array(
'url' => 'path/to/link" target="_blank"',
'title' => 'Link title',
'groups' => array('group1', 'group2'),
'icon' => 'path/to/icon'
);
Wilfredo
$navLinks[] = array(
'url' => 'path/to/link" target="_blank"',
'title' => 'Link title',
'groups' => array('group1', 'group2'),
'icon' => 'path/to/icon'
);
Wilfredo