Popular Posts Widget

Adding popular posts widget.
This commit is contained in:
Danang Probo Sayekti 2015-07-30 07:50:46 +07:00
commit 7c28567d1c
7 changed files with 236 additions and 29 deletions

View file

@ -456,6 +456,24 @@ iframe {
margin-bottom: 0;
}
/* popular-posts Section */
.popular-posts .item {
margin-bottom: 20px;
}
.popular-posts .item .title {
font-size: 16px;
line-height: 1.3;
}
.popular-posts .item .title a {
color: #778492;
}
.popular-posts .item .title a:hover {
color: #5f6b77;
}
.popular-posts .item:last-child {
margin-bottom: 0;
}
/* archive Section */
ul.archivegroup {
margin: 0;

View file

@ -115,6 +115,25 @@
<?php endforeach;?>
</div><!--//section-inner-->
</aside><!--//section-->
<?php if (config('views.counter') === 'true') :?>
<aside class="popular-posts aside section">
<div class="section-inner">
<h2 class="heading">Popular Blog Posts</h2>
<?php $lists = popular_posts(true);?>
<?php $char = 60;?>
<?php foreach ($lists as $l):?>
<?php if (strlen(strip_tags($l->title)) > $char) { $recentTitle = shorten($l->title, $char) . '...';} else {$recentTitle = $l->title;}?>
<div class="item">
<h3 class="title"><a href="<?php echo $l->url;?>"><?php echo $recentTitle;?></a></h3>
<div class="content">
<p><?php echo shorten($l->body, 75); ?>...</p>
<a class="more-link" href="<?php echo $l->url;?>"><i class="fa fa-link"></i> Read more</a>
</div><!--//content-->
</div>
<?php endforeach;?>
</div><!--//section-inner-->
</aside><!--//section-->
<?php endif;?>
<?php if (disqus()): ?>
<aside class="comments aside section">
<div class="section-inner">
@ -139,11 +158,10 @@
<div class="section-inner">
<h2 class="heading">Tags</h2>
<div class="tag-cloud">
<?php $tags = tag_cloud(true); if(is_array($tags)) { ?>
<?php foreach ($tags as $tag => $count):?>
<a class="more-link" href="<?php echo site_url();?>tag/<?php echo $tag;?>"><?php echo $tag;?></a>
<?php endforeach;?>
<?php } ?>
<?php $tags = tag_cloud(true);?>
<?php foreach ($tags as $tag => $count):?>
<a class="more-link" href="<?php echo site_url();?>tag/<?php echo $tag;?>"><?php echo $tag;?></a>
<?php endforeach;?>
</div><!--//content-->
</div><!--//section-inner-->
</aside><!--//section-->
@ -161,4 +179,4 @@
<script type="text/javascript" src="<?php echo site_url();?>themes/blog/js/bootstrap.min.js"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>
</html>
</html>

View file

@ -608,15 +608,15 @@ ul li, ol li {
margin: 0;
}
.about, .social, .archive, .comments, .tagcloud, .recent {
.about, .social, .archive, .comments, .tagcloud, .recent, .popular {
margin-bottom: 2em;
}
#sidebar .recent ul {
#sidebar .recent ul, #sidebar .popular ul {
margin: 0.25em 0 0.25em 1.3em;
}
#sidebar .recent li {
#sidebar .recent li, #sidebar .popular li {
list-style-type: circle;
}

View file

@ -57,6 +57,12 @@
<h3>Recent Posts</h3>
<?php echo recent_posts() ?>
</div>
<?php if(config('views.counter') === 'true') :?>
<div class="popular">
<h3>Popular Posts</h3>
<?php echo popular_posts() ?>
</div>
<?php endif;?>
<div class="archive">
<h3>Archive</h3>
<?php echo archive_list() ?>