From f51f27d4d99b4b37a4f07cc7dd0f73b87edbc10d Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Sun, 12 Jan 2014 18:41:13 +0700 Subject: [PATCH] Search form + perfomance Improve search form + perfomance. --- system/includes/functions.php | 35 +++++++++++++++++++++++------------ themes/clean/404-search.html.php | 6 +----- themes/clean/layout.html.php | 6 +----- themes/default/404-search.html.php | 6 +----- themes/default/css/style.css | 2 +- themes/default/layout.html.php | 6 +----- 6 files changed, 28 insertions(+), 33 deletions(-) diff --git a/system/includes/functions.php b/system/includes/functions.php index 5582f64..1706d70 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -510,12 +510,9 @@ function get_bio($names, $author){ foreach($names as $index => $v){ $post = new stdClass; - - // Extract the array - $arr = explode('_', $v); // Replaced string - $replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/'; + $replaced = substr($v, 0,strrpos($v, '/')) . '/'; // Author string $str = explode('/', $replaced); @@ -523,7 +520,7 @@ function get_bio($names, $author){ if($author === $profile){ // Profile URL - $url = str_replace($replaced,'',$arr[0]); + $url = str_replace($replaced,'',$v); $post->url = site_url() . 'author/' . $profile; // Get the contents and convert it to HTML @@ -849,7 +846,21 @@ function menu(){ } } -// Auto generated menu from static page +// Menu +function search() { + echo << + + + +EOF; + if(isset($_GET['search'])) { + $url = site_url() . 'search/' . $_GET['search']; + header ("Location: $url"); + } +} + +// Auto generate menu from static page function get_menu() { $posts = get_spage_names(); @@ -859,13 +870,13 @@ function get_menu() { echo '
  • Home
  • '; foreach($posts as $index => $v){ - // Replaced string - $replaced = substr($v, 0, strrpos($v, '/')) . '/'; + // Replaced string + $replaced = substr($v, 0, strrpos($v, '/')) . '/'; - // The static page URL - $title = str_replace($replaced,'',$v); - $url = site_url() . str_replace('.md','',$title); - echo '
  • ' . ucfirst(str_replace('.md','',$title)) . '
  • '; + // The static page URL + $title = str_replace($replaced,'',$v); + $url = site_url() . str_replace('.md','',$title); + echo '
  • ' . ucfirst(str_replace('.md','',$title)) . '
  • '; } echo ''; diff --git a/themes/clean/404-search.html.php b/themes/clean/404-search.html.php index 5749ea9..400020a 100644 --- a/themes/clean/404-search.html.php +++ b/themes/clean/404-search.html.php @@ -14,11 +14,7 @@

    Search results not found!

    Please search again, or would you like to try our homepage instead?

    diff --git a/themes/clean/layout.html.php b/themes/clean/layout.html.php index b77871d..44e217c 100644 --- a/themes/clean/layout.html.php +++ b/themes/clean/layout.html.php @@ -25,11 +25,7 @@

    diff --git a/themes/default/404-search.html.php b/themes/default/404-search.html.php index 16cae84..67b6208 100644 --- a/themes/default/404-search.html.php +++ b/themes/default/404-search.html.php @@ -14,11 +14,7 @@

    Search results not found!

    -
    - - -
    - +

    Please search again, or would you like to try our homepage instead?

    diff --git a/themes/default/css/style.css b/themes/default/css/style.css index 61b8833..146a8cb 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -596,7 +596,7 @@ h1.title-post a:hover, h2.title-index a:hover { margin-bottom: 1.2em; } -#search-form-404 { +.search-404 #search-form { float:none; } diff --git a/themes/default/layout.html.php b/themes/default/layout.html.php index e0703b9..664e1a2 100644 --- a/themes/default/layout.html.php +++ b/themes/default/layout.html.php @@ -26,11 +26,7 @@