Skip to content

Instantly share code, notes, and snippets.

@katzueno katzueno/vew.php
Last active Aug 31, 2018

Embed
What would you like to do?
concrete5 Manual Nav custom template to support external link's new window and nav_target page attribute
<?php defined('C5_EXECUTE') or die(_("Access Denied."));
/**
* concrete5.6.x Package 'Manual Nav' Custom Template
* @package Manual Nav
* @author Jordan Lev
* @author Katz Ueno
* @copyright Copyright (c) 2015 Katz Ueno. (http://katzueno.com)
* @license http://www.concrete5.org/license/ MIT License
* to support External Link's tareget="_blank"
* and page attribute 'nav_target'
*
* I know I should be doing this in controller.php
*
* concrete5.6.x パッケージ 「Manual Nav」
* 外部リンクの「新しいウインドウ」
* ページ属性の「nav_target」に対応するためのカスタムテンプレート
* 本来なら controller.php でやるべきなのも分かるんですが、面倒臭かったので・・・
*/
?>
<ul>
<?php foreach ($links as $link):
$page = $link->cObj;
$target = '';
if ($page->cPointerExternalLink != '') {
if ($page->cPointerExternalLinkNewWindow) {
$target ='_blank';
}
} else {
if ($page->getAttribute('nav_target')) {
$target = $page->getAttribute('nav_target');
}
}
?>
<li>
<a href="<?php echo $link->url; if ($target) echo '" target="' . $target ?>">
<?php echo htmlentities($link->text, ENT_QUOTES, APP_CHARSET); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.