function tag_cloud($custom = null) { $dir = "cache/widget"; $filename = "cache/widget/tags.cache"; $tg = array(); if (is_dir($dir) === false) { mkdir($dir, 0775, true); } $posts = get_post_unsorted(); $tags = array(); if (!empty($posts)) { if (!file_exists($filename)) { foreach ($posts as $index => $v) { $arr = explode('_', $v); $data = rtrim($arr[1], ','); $mtag = explode(',', $data); foreach ($mtag as $etag) { $tags[] = strtolower($etag); } } $tag_collection = array_count_values($tags); ksort($tag_collection); $tg = serialize($tag_collection); file_put_contents($filename, print_r($tg, true)); } else { $tag_collection = unserialize(file_get_contents($filename)); } if (empty($custom)) { echo '<ul class="taglist">'; foreach ($tag_collection as $tag => $count) { echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . tag_i18n($tag) . '</a> <span class="count">(' . $count . ')</span></li>'; } echo '</ul>'; } else { return $tag_collection; } } else { if (empty($custom)) { return; } return $tags; } }
<h2 class="heading">Tags</h2> <div class="tag-cloud"> <?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_i18n($tag); ?> </a> <?php } ?> </div><!--//content--> </div><!--//section-inner--> </aside><!--//section--> </div><!--//secondary--> </div><!--//row--> </div><!--//masonry--> <!-- ******FOOTER****** --> <footer class="footer"> <div class="container text-center"> <?php
if (!login()) { file_cache($_SERVER['REQUEST_URI']); } $page = from($_GET, 'page'); $page = $page ? (int) $page : 1; $perpage = config('search.perpage'); $posts = get_keyword($keyword, $page, $perpage); $tsearch = new stdClass(); $tsearch->title = $keyword; if (!$posts || $page < 1) { // a non-existing page or no search result render('404-search', array('title' => 'Search results not found! - ' . blog_title(), 'description' => 'Search results not found!', 'search' => $tsearch, 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » No search results', 'canonical' => site_url(), 'bodyclass' => 'error-404-search', 'is_404search' => true)); die; } $total = keyword_count($keyword); render('main', array('title' => 'Search results for: ' . tag_i18n($keyword) . ' - ' . blog_title(), 'description' => 'Search results for: ' . tag_i18n($keyword) . ' on ' . blog_title() . '.', 'canonical' => site_url() . 'search/' . strtolower($keyword), 'page' => $page, 'posts' => $posts, 'search' => $tsearch, 'bodyclass' => 'insearch', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Search results for: ' . tag_i18n($keyword), 'pagination' => has_pagination($total, $perpage, $page), 'is_search' => true)); }); // The JSON API get('/api/json', function () { header('Content-type: application/json'); $page = from($_GET, 'page'); $page = $page ? (int) $page : 1; $perpage = config('json.count'); echo generate_json(get_posts(null, $page, $perpage)); }); // Show the RSS feed get('/feed/rss', function () { header('Content-Type: application/rss+xml'); // Show an RSS feed with the 30 latest posts echo generate_rss(get_posts(null, 1, config('rss.count'))); });