index.php
update the loop to display a category template, it should look like this
Code: Select all
if ($WHERE_AM_I == 'page') {
include(THEME_DIR_PHP.'page.php');
} elseif ($WHERE_AM_I=='category') {
include(THEME_DIR_PHP.'category.php');
} else {
include(THEME_DIR_PHP.'home.php');
}
category.php
create the template file in the php folder. you can copy home.php but it would be better to do this
Code: Select all
<div class="container">
<div class="section-title">
<h2><span><?php $category = getCategory($categoryKey); echo $category->name(); ?></span></h2>
</div>
<div class="card-columns listrecent">
<?php if (empty($content)) { $language->p('No pages found'); } ?>
<?php foreach ($content as $page): ?>
<div class="card">
<a href="<?php echo $page->permalink(); ?>">
<div style="background-image:url(<?php echo ($page->coverImage()?$page->coverImage():Theme::src('img/noimage.png')) ?>); background-size: cover; background-position: center; width:100%; height:250px;"></div>
</a>
<div class="card-block p-3">
<h2 class="card-title"><a href="<?php echo $page->permalink(); ?>"><?php echo $page->title(); ?></a></h2>
<h4 class="card-text"><?php echo (empty($page->description())?$language->p('Complete the description of the article'):$page->description()) ?></h4>
<div class="metafooter">
<div class="wrapfooter">
<span class="meta-footer-thumb">
<img class="author-thumb" src="<?php echo ($page->user('profilePicture')?$page->user('profilePicture'):Theme::src('img/noimage.png')) ?>" alt="<?php echo $page->user('nickname') ?>">
</span>
<span class="author-meta">
<span class="post-name"><?php echo $page->user('nickname'); ?></span><br/>
<span class="post-date"><?php echo $page->date(); ?></span><span class="dot"></span><span class="post-read"><?php echo $page->readingTime(); ?></span>
</span>
<span class="post-read-more"><a href="<?php echo $page->permalink(); ?>" title="Read Story"><svg class="svgIcon-use" width="25" height="25" viewbox="0 0 25 25"><path d="M19 6c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v14.66h.012c.01.103.045.204.12.285a.5.5 0 0 0 .706.03L12.5 16.85l5.662 4.126a.508.508 0 0 0 .708-.03.5.5 0 0 0 .118-.285H19V6zm-6.838 9.97L7 19.636V6c0-.55.45-1 1-1h9c.55 0 1 .45 1 1v13.637l-5.162-3.668a.49.49 0 0 0-.676 0z" fill-rule="evenodd"></path></svg></a></span>
</div>
</div>
</div>
</div>
<?php endforeach ?>
</div>
<?php if (Paginator::numberOfPages()>1): ?>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<?php if (Paginator::showPrev()): ?>
<li class="page-item"><a class="page-link" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1">◀ <?php $language->p('Previous page') ?></a></li>
<?php endif ?>
<?php if (Paginator::showNext()): ?>
<li class="page-item"><a class="page-link" href="<?php echo Paginator::nextPageUrl() ?>"><?php $language->p('Next page') ?> ►</a></li>
<?php endif ?>
</ul>
</nav>
<?php endif ?>
<div class="footer">
<p class="pull-left">
<?php echo $site->footer(); ?>
</p>
<p class="pull-right">
Designed by <a target="_blank" href="https://www.wowthemes.net">Wowthemes</a> |
Powered by <a target="_blank" href="https://www.bludit.com">Bludit.com</a>
</p>
<div class="clearfix">
</div>
</div>
</div>
home.php
find author-meta span, inside that, next to the user name add category, should look something like this
Code: Select all
<span class="post-name"><?php echo $page->user('nickname'); ?></span>
<?php
if ($page->categoryKey()){
$categoryKey = $page->categoryKey();
$category = getCategory($categoryKey);
echo ', <a href="'.$category->permalink().'">'.$category->name().'</a> ';
};
?>
<br/>
topbar.php
add categories to the menu - find static pages loop and after endforeach add this
Code: Select all
$items = getCategories();
foreach ($items as $category) {
if (count($category->pages())>0) {
echo '<li class="nav-item">';
echo '<a class="nav-link" href="'. $category->permalink().'">';
echo $category->name();
echo '</a></li>';
}
}
DONE!