Skip to content

Commit

Permalink
bc_sample のパンくずを 構造化出力 に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Mar 9, 2021
1 parent 3999929 commit 1c400e9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 37 deletions.
75 changes: 42 additions & 33 deletions lib/Baser/Config/theme/bc_sample/Elements/crumbs.php
Expand Up @@ -4,51 +4,60 @@
* Copyright (c) baserCMS Users Community <https://basercms.net/community/>
*
* @copyright Copyright (c) baserCMS Users Community
* @link https://basercms.net baserCMS Project
* @link https://basercms.net baserCMS Project
* @package Baser.View
* @since baserCMS v 4.4.0
* @license https://basercms.net/license/index.html
*/

/**
* パンくずナビゲーション
* [PUBLISH] ナビゲーション
*
* BcBaserHelper::crumbsList() で呼び出す
* (例)<?php $this->BcBaser->crumbsList() ?>
*
* @var BcAppView $this
* ページタイトルが直属のカテゴリ名と同じ場合は、直属のカテゴリ名を省略する
*/
?>


<div class="bs-crumbs">
<?php
if ($this->BcBaser->isHome()) {
echo '<strong>'. __('ホーム').'</strong>';
} else {
$crumbs = $this->BcBaser->getCrumbs();
if (!empty($crumbs)) {
foreach ($crumbs as $key => $crumb) {
if ($this->BcArray->last($crumbs, $key + 1)) {
if ($crumbs[$key + 1]['name'] == $crumb['name']) {
continue;
}
}
if ($this->BcArray->last($crumbs, $key)) {
if ($this->viewPath != 'home' && $crumb['name']) {
$this->BcBaser->addCrumb('<strong>' . h($crumb['name']) . '</strong>');
}
} else {
$this->BcBaser->addCrumb(h($crumb['name']), $crumb['url']);
if (!isset($separator)) {
$separator = '&nbsp;&gt;&nbsp;';
}
if (!isset($home)) {
$home = __d('baser', 'ホーム');
}
$crumbs = $this->BcBaser->getCrumbs();
if (!empty($crumbs)) {
foreach($crumbs as $key => $crumb) {
if ($this->BcArray->last($crumbs, $key)) {
if ($this->viewPath != 'home' && $crumb['name']) {
$this->BcBaser->addCrumb(h($crumb['name']));
}
} else {
$this->BcBaser->addCrumb(h($crumb['name']), $crumb['url']);
}
}
elseif (empty($crumbs)) {
if ($this->name == 'CakeError') {
$this->BcBaser->addCrumb('<strong>404 NOT FOUND</strong>');
}
} elseif (empty($crumbs)) {
if ($this->name == 'CakeError') {
$this->BcBaser->addCrumb('404 NOT FOUND');
}
$this->BcBaser->crumbs(' &gt; ', __('ホーム'));
}
?>

<div class="bs-crumbs">
<?php if (empty($onSchema)): ?>
<?php
if ($this->BcBaser->isHome()) {
echo $home;
} else {
$this->BcBaser->crumbs($separator, $home);
}
?>
<?php else: ?>
<ul itemscope itemtype="http://schema.org/BreadcrumbList">
<?php if ($this->BcBaser->isHome()): ?>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><span
itemprop="name"><?php echo $home ?></span>
<meta itemprop="position" content="1"/>
</li>
<?php else: ?>
<?php $this->BcBaser->crumbs($separator, $home, true) ?>
<?php endif ?>
</ul>
<?php endif ?>
</div>
2 changes: 1 addition & 1 deletion lib/Baser/Config/theme/bc_sample/Layouts/default.php
Expand Up @@ -55,7 +55,7 @@
<?php $this->BcBaser->mainImage(['all' => true, 'num' => 5, 'width' => '100%', 'class' => 'bs-main-image']) ?>
<?php else: ?>
<!-- /Elements/crumbs.php -->
<?php $this->BcBaser->crumbsList(); ?>
<?php $this->BcBaser->crumbsList(['onSchema' => true]); ?>
<?php endif ?>

<div class="bs-wrap clearfix">
Expand Down
Expand Up @@ -175,6 +175,7 @@
font-size: 12px;
color: #CCC;
box-sizing: border-box;
line-height: 2em;
@include bs-mq() {
box-sizing: border-box;
width: 100%;
Expand All @@ -197,6 +198,14 @@
color: #555;
}
}

ul {
display: flex;
list-style: none;
margin-left: 0;
padding-left: 0;
flex-wrap: wrap;
}
}

/* Contents Navigation
Expand Down
9 changes: 8 additions & 1 deletion lib/Baser/Config/theme/bc_sample/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/Baser/View/Elements/crumbs.php
Expand Up @@ -39,7 +39,7 @@
}
?>


<div class="bs-crumbs">
<?php if (empty($onSchema)): ?>
<?php
if ($this->BcBaser->isHome()) {
Expand All @@ -57,4 +57,4 @@
<?php endif ?>
</ul>
<?php endif ?>

</div>

0 comments on commit 1c400e9

Please sign in to comment.