Skip to content

Commit

Permalink
Merge pull request #10 from fordes123/dev
Browse files Browse the repository at this point in the history
侧边栏子分类点击动作
  • Loading branch information
fordes123 authored Mar 25, 2024
2 parents 519ba25 + dcc8895 commit c6afc28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
$children = $categories->getAllChildren($categories->mid);
if (empty($children)) { ?>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a onclick="<?php if ($this->is('index')) : ?>document.getElementById('<?php $categories->slug() ?>').scrollIntoView({behavior: 'smooth', block: 'center'});<?php else : ?>window.location.href = '/';<?php endif; ?>" aria-current="page">
<?php $onclick = $this->is('index') ? "document.getElementById('" . $categories->slug . "').scrollIntoView({behavior: 'smooth', block: 'center'})" : "window.location.href = '/'"; ?>
<a onclick="<?php echo $onclick; ?>" aria-current="page">
<span class="menu-icon"><i class="fas fa-<?php $categories->slug(); ?> fa-sm"></i></span>
<span class="menu-text"><?php $categories->name() ?></span>
</a>
Expand All @@ -29,7 +30,8 @@
<?php foreach ($children as $mid) { ?>
<?php $child = $categories->getCategory($mid); ?>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a onclick="<?php if ($this->is('index')) : ?>document.getElementById('<?php $child['slug'] ?>').scrollIntoView({behavior: 'smooth', block: 'center'});<?php else : ?>window.location.href = '/';<?php endif; ?>">
<?php $onclick = $this->is('index') ? "document.getElementById('" . $child['slug'] . "').scrollIntoView({behavior: 'smooth', block: 'center'})" : "window.location.href = '/'"; ?>
<a onclick="<?php echo $onclick; ?>" aria-current="page">
<span class="menu-text"><?php echo $child['name'] ?></span>
</a>
</li>
Expand Down

0 comments on commit c6afc28

Please sign in to comment.