Last active
April 5, 2016 05:28
-
-
Save kanetei/070ed42cba5ffc617ad0 to your computer and use it in GitHub Desktop.
[concrete5] オートナビの出力をページ属性の値でグルーピングする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('C5_EXECUTE') or die("Access Denied."); | |
// application/blocks/autonav/templates/grouping_autonav/view.php | |
$navItems = $controller->getNavItems(); | |
$c = Page::getCurrentPage(); | |
function cmp($a, $b) | |
{ | |
$cmp = strcmp($a->cObj->getAttribute('attribute'), $b->cObj->getAttribute('attribute')); | |
return $cmp; | |
} | |
usort($navItems , "cmp"); | |
//*** Output menu HTML ***/ | |
if (count($navItems) > 0) { | |
?> | |
<ul> | |
<?php | |
$attribute = ""; | |
foreach ($navItems as $ni) { | |
if (empty($attribute)) { | |
?> | |
<li><a href="#"><?php echo $ni->cObj->getAttribute('attribute'); ?></a> | |
<ul> | |
<?php | |
}elseif ( $house_area != $ni->cObj->getAttribute('attribute') ) { | |
?> | |
</ul> | |
</li> | |
<li><a href="#"><?php echo $ni->cObj->getAttribute('attribute'); ?></a> | |
<ul> | |
<?php | |
} | |
?> | |
<li><a href="<?php echo $ni->url; ?>" target="<?php echo $ni->target; ?>"><?php echo $ni->name; ?></a></li> | |
<?php | |
if($ni === end($navItems)) { | |
?> | |
</ul> | |
</li> | |
<?php | |
} | |
$attribute = $ni->cObj->getAttribute('attribute'); | |
} | |
?> | |
</ul> | |
<?php | |
} else if (is_object($c) && $c->isEditMode()) { ?> | |
<div class="ccm-edit-mode-disabled-item"><?php echo t('Empty Auto-Nav Block.')?></div> | |
<?php } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment