Skip to content

Instantly share code, notes, and snippets.

@kanetei
Created December 10, 2019 22:58
Show Gist options
  • Save kanetei/9a640ed74d34578b5766f9cd1ab8ba9a to your computer and use it in GitHub Desktop.
Save kanetei/9a640ed74d34578b5766f9cd1ab8ba9a to your computer and use it in GitHub Desktop.
【concrete5】日付ナビで日付毎の件数を表示するサンプルコード
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<aside class="blog-sidenav__list">
<h5 class="list-title"><?=h($title)?></h5>
<p class="view-all"><a href="<?=URL::to('/store/blog/archive')?>">一覧を見る</a></p>
<?php if (count($dates)) { ?>
<ul class="list-archive row">
<?php foreach ($dates as $date) { ?>
<li class="medium-6 columns<?php
if($date === end($dates)) {
echo ' end';
}
?>"><a class="archive-link" href="<?=$view->controller->getDateLink($date)?>"<?php
if ($view->controller->isSelectedDate($date)) {
?> class="selected"<?php
}
?>><?=$view->controller->getDateLabel($date)?>年(<?php
$list = new \Concrete\Core\Page\PageList();
$list->filterByPageTypeHandle('store_blog');
$year = $view->controller->getDateLabel($date);
$yearStart = $year.'-01-01';
$list->filterByPublicDate($yearStart,'>=');
$yearEnd = $year.'-12-31';
$list->filterByPublicDate($yearEnd,'<=');
$pages = $list->getResults();
echo count($pages);
?>)</a></li>
<?php } ?>
</ul>
<?php } else { ?>
<p><?=t('None.')?></p>
<?php } ?>
</aside>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment