Browse Source

Dynamic heading

Dynamic heading for themer, there is is_index function.
pull/31/merge
Danang Probo Sayekti 11 years ago
parent
commit
b59d9ffd55
7 changed files with 142 additions and 105 deletions
  1. +121
    -96
      system/includes/functions.php
  2. +3
    -3
      themes/clean/css/style.css
  3. +5
    -2
      themes/clean/layout.html.php
  4. +2
    -1
      themes/default/css/style.css
  5. +5
    -1
      themes/default/layout.html.php
  6. +1
    -1
      themes/logs/css/style.css
  7. +5
    -1
      themes/logs/layout.html.php

+ 121
- 96
system/includes/functions.php View File

@ -438,7 +438,7 @@ function get_keyword($keyword, $page, $perpage){
$arr = explode('_', $v['filename']);
$filter = $arr[1] .' '. $arr[2];
foreach($words as $word) {
if(strpos($filter, strtolower($word)) !== false) {
if(stripos($filter, $word) !== false) {
$tmp[] = $v;
}
}
@ -533,72 +533,76 @@ function archive_list() {
$by_year = array();
$col = array();
foreach($posts as $index => $v){
if(!empty($posts)) {
$arr = explode('_', $v);
foreach($posts as $index => $v){
// Replaced string
$str = $arr[0];
$replaced = substr($str, 0,strrpos($str, '/')) . '/';
$arr = explode('_', $v);
// Replaced string
$str = $arr[0];
$replaced = substr($str, 0,strrpos($str, '/')) . '/';
$date = str_replace($replaced,'',$arr[0]);
$data = explode('-', $date);
$col[] = $data;
}
$date = str_replace($replaced,'',$arr[0]);
$data = explode('-', $date);
$col[] = $data;
foreach ($col as $row){
}
foreach ($col as $row){
$y = $row['0'];
$m = $row['1'];
$by_year[$y][] = $m;
$y = $row['0'];
$m = $row['1'];
$by_year[$y][] = $m;
}
# Most recent year first
krsort($by_year);
# Iterate for display
$script = <<<EOF
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '&#9658;';} else {this.parentNode.className = 'expanded';this.innerHTML = '&#9660;';}
}
# Most recent year first
krsort($by_year);
# Iterate for display
$script = <<<EOF
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '&#9658;';} else {this.parentNode.className = 'expanded';this.innerHTML = '&#9660;';}
EOF;
echo <<<EOF
<style>ul.archivegroup{padding:0;margin:0;}.archivegroup .expanded ul{display:block;}.archivegroup .collapsed ul{display:none;}.archivegroup li.expanded,.archivegroup li.collapsed{list-style:none;}
</style>
echo <<<EOF
<style>ul.archivegroup{padding:0;margin:0;}.archivegroup .expanded ul{display:block;}.archivegroup .collapsed ul{display:none;}.archivegroup li.expanded,.archivegroup li.collapsed{list-style:none;}
</style>
EOF;
echo '<h3>Archive</h3>';
$i = 0;
$len = count($by_year);
foreach ($by_year as $year => $months){
if ($i == 0) {
$class = 'expanded';
$arrow = '&#9660;';
}
else {
$class = 'collapsed';
$arrow = '&#9658;';
}
$i++;
echo '<ul class="archivegroup">';
echo '<li class="' . $class . '">';
echo '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
echo '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
echo '<span class="count">(' . count($months) . ')</span>';
echo '<ul class="month">';
$by_month = array_count_values($months);
# Sort the months
krsort($by_month);
foreach ($by_month as $month => $count){
$name = date('F', mktime(0,0,0,$month,1,2010));
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
echo ' <span class="count">(' . $count . ')</span></li>';
}
echo '<h3>Archive</h3>';
$i = 0;
$len = count($by_year);
foreach ($by_year as $year => $months){
if ($i == 0) {
$class = 'expanded';
$arrow = '&#9660;';
}
else {
$class = 'collapsed';
$arrow = '&#9658;';
}
$i++;
echo '<ul class="archivegroup">';
echo '<li class="' . $class . '">';
echo '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
echo '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
echo '<span class="count">(' . count($months) . ')</span>';
echo '<ul class="month">';
$by_month = array_count_values($months);
# Sort the months
krsort($by_month);
foreach ($by_month as $month => $count){
$name = date('F', mktime(0,0,0,$month,1,2010));
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
echo ' <span class="count">(' . $count . ')</span></li>';
}
echo '</ul>';
echo '</li>';
echo '</ul>';
echo '</ul>';
echo '</li>';
echo '</ul>';
}
}
}
@ -609,27 +613,31 @@ function tag_cloud() {
$posts = get_post_unsorted();
$tags = array();
foreach($posts as $index => $v){
if(!empty($posts)) {
$arr = explode('_', $v);
foreach($posts as $index => $v){
$data = $arr[1];
$mtag = explode(',', $data);
foreach($mtag as $etag) {
$tags[] = $etag;
$arr = explode('_', $v);
$data = $arr[1];
$mtag = explode(',', $data);
foreach($mtag as $etag) {
$tags[] = $etag;
}
}
}
$tag_collection = array_count_values($tags);
ksort($tag_collection);
$tag_collection = array_count_values($tags);
ksort($tag_collection);
echo '<h3>Tags</h3>';
echo '<ul class="taglist">';
foreach ($tag_collection as $tag => $count){
echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . $tag . '</a> <span class="count">(' . $count . ')</span></li>';
}
echo '</ul>';
echo '<h3>Tags</h3>';
echo '<ul class="taglist">';
foreach ($tag_collection as $tag => $count){
echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . $tag . '</a> <span class="count">(' . $count . ')</span></li>';
}
echo '</ul>';
}
@ -1237,36 +1245,39 @@ function generate_sitemap($str){
$posts = get_post_unsorted();
$tags = array();
foreach($posts as $index => $v){
$arr = explode('_', $v);
if(!empty($posts)) {
foreach($posts as $index => $v){
$data = $arr[1];
$mtag = explode(',', $data);
foreach($mtag as $etag) {
$tags[] = $etag;
$arr = explode('_', $v);
$data = $arr[1];
$mtag = explode(',', $data);
foreach($mtag as $etag) {
$tags[] = $etag;
}
}
}
foreach($tags as $t) {
$tag[] = site_url() . 'tag/' . $t;
}
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if(isset($tag)) {
$tag = array_unique($tag, SORT_REGULAR);
foreach($tags as $t) {
$tag[] = site_url() . 'tag/' . $t;
}
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if(isset($tag)) {
$tag = array_unique($tag, SORT_REGULAR);
foreach($tag as $t) {
echo '<url><loc>' . $t . '</loc><priority>0.5</priority></url>';
}
foreach($tag as $t) {
echo '<url><loc>' . $t . '</loc><priority>0.5</priority></url>';
}
echo '</urlset>';
}
echo '</urlset>';
}
elseif ($str == 'archive') {
@ -1369,6 +1380,20 @@ function is_front() {
}
}
// TRUE if the current page is an index page like frontpage, tag index, archive index and search index.
function is_index() {
$req = $_SERVER['REQUEST_URI'];
if(strpos($req, 'archive') !== false || strpos($req, 'tag') !== false || strpos($req, 'search') !== false){
return true;
}
elseif($req == site_path() . '/') {
return true;
}
else {
return false;
}
}
// Return blog title
function blog_title() {
return config('blog.title');


+ 3
- 3
themes/clean/css/style.css View File

@ -56,19 +56,19 @@ h1{
margin: 0.5em 0;
}
h1.blog-title {
h1.blog-title, h2.blog-title {
text-transform:uppercase;
font: 20px 'Open Sans Condensed', sans-serif;
margin-bottom: 1em;
line-height: 1.3;
}
h1.blog-title a {
h1.blog-title a, h2.blog-title a {
color:#4f4f4f;
text-decoration: none;
}
h1.blog-title a:hover {
h1.blog-title a:hover, h2.blog-title a:hover {
color: #389dc1;
}


+ 5
- 2
themes/clean/layout.html.php View File

@ -17,8 +17,11 @@
<?php if(facebook()) { echo facebook();} ?>
<?php if(login()) { toolbar();} ?>
<aside>
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
<?php if(is_index()) {?>
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<?php } else {?>
<h2 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h2>
<?php } ?>
<div class="search">
<?php echo search() ?>
</div>


+ 2
- 1
themes/default/css/style.css View File

@ -469,8 +469,9 @@ p, ul {
margin:1em 0;
}
h1.blog-title {
h1.blog-title, h2.blog-title {
font-style:normal;
font-size: 28px;
}
h1.title-post a, h2.title-index a{


+ 5
- 1
themes/default/layout.html.php View File

@ -29,7 +29,11 @@
<div class="container">
<header id="header">
<section id="branding">
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<?php if(is_index()) {?>
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<?php } else {?>
<h2 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h2>
<?php } ?>
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
</section>
</header>


+ 1
- 1
themes/logs/css/style.css View File

@ -251,7 +251,7 @@ ul li, ol li{
margin-top:5px;
}
#branding h1 {
#branding h1, #branding h2 {
font-size: 36px;
font-family: Georgia,sans-serif;
margin:0;


+ 5
- 1
themes/logs/layout.html.php View File

@ -20,7 +20,11 @@
<div id="header-wrapper">
<header id="header" class="responsive">
<div id="branding">
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<?php if(is_index()) {?>
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<?php } else {?>
<h2 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h2>
<?php } ?>
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
</div>
</header>


Loading…
Cancel
Save