Skip to content

Instantly share code, notes, and snippets.

@katzueno
Last active August 31, 2018 07:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katzueno/39037994cac9949bd8bc to your computer and use it in GitHub Desktop.
Save katzueno/39037994cac9949bd8bc to your computer and use it in GitHub Desktop.
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