(2013-08-09, 06:13:10)bensayers Wrote:(2013-07-14, 17:19:00)mvlcek Wrote:(2013-07-14, 08:30:48)bensayers Wrote: How can I make the external links open in a new window (_blank)? I've searched through the boards and documentation but I can't find the way it's done...
You would need to use Custom rendering and add the target to the <a>, when the link is external.
Can someone please help me with this issue? Seems like this should be a pretty common request - why wouldn't you want an external link to open in a new window?
Call
PHP Code:
<?php get_i18n_navigation(get_page_slug(false), 0, 0, I18N_SHOW_NORMAL, 'navigation'); ?>
Component (named 'navigation') - note: this was modified from mvlcek's example on his site
PHP Code:
<?php global $SITEURL; ?>
<li class="<?php echo $item->classes; ?>">
<a href="<?php echo htmlspecialchars($item->link); ?>" <?php if (strpos($SITEURL, htmlspecialchars($item->link)) !== 0) echo 'target="_blank"';?>>
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php if ($item->isOpen) { ?>
<ul><?php $item->outputChildren(); ?></ul>
<?php } ?>
</li>
Key parts are:
PHP Code:
<?php global $SITEURL; ?>
(Gives site url for use in IF conditional)
PHP Code:
<?php if (strpos($SITEURL, htmlspecialchars($item->link)) !== 0) echo 'target="blank"'; ?>
(Says if the site url isn't found in the menu item's link, it's external, hence output 'target="_blank"').
Note: If get_page_slug(false) doesn't work, use return_page_slug() (I just used whichever one was in the latest GetSimple version, which at the time of speaking is 3.2.2).