rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

commit eb42fa567320953fad8f071c3b8467a44c0f9705
parent d9a74ce468f79d4e2585911e828ad4cc14994752
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 13 Dec 2014 13:19:53 +0100

add same function for author :D

Diffstat:
Mcore/backend/blog/posts.php | 43+++++++++++++++++++++++++++++++++++++++++++
Mthemes/jumbotron/index.php | 79++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
2 files changed, 101 insertions(+), 21 deletions(-)

diff --git a/core/backend/blog/posts.php b/core/backend/blog/posts.php @@ -27,11 +27,22 @@ } #$resultat->close(); } + if ($resultat = $connection->query("SELECT * FROM posts WHERE author LIKE '$author'")) { + while($daten = $resultat->fetch_object() ){ + $author_id_clean = $daten->id; + #var_dump($daten); + } + #$resultat->close(); + } next_id_only(); next_id_category(); + next_id_author(); function next_id_category(){ read_category(); } + function next_id_author(){ + read_author(); + } function next_id_only(){ read_only(); } @@ -100,6 +111,38 @@ } } +function read_author(){ + global $id, $author, $connection, $read, $author_id_clean; + global $post_id, $post_title, $post_text, $post_author, $post_date, $post_category, $post_text_short; + if ($resultat = $connection->query("SELECT * FROM posts WHERE author LIKE '$category' AND id LIKE '$id'")) { + //echo 'SELECT * FROM posts WHERE id LIKE '.$id; + //Put database data in variables + while($daten = $resultat->fetch_object() ){ + //var_dump ($daten); + $post_id = $daten->id; + $post_title = $daten->title; + $post_text = $daten->text; + $post_author = $daten->author; + $post_date = $daten->date; + $post_category = $daten->category; + $post_text_short = shortText($post_text,300); + } + $resultat->close(); + } else { + global $id, $author, $connection, $read, $author_id_clean; + global $post_id, $post_title, $post_text, $post_author, $post_date, $post_category; + global $error; + $error = "1"; + echo "Nothing to read from Database!"; + $post_id = "Database error!"; + $post_title = "Database error!"; + $post_text = "Database error!"; + $post_author = "Database error!"; + $post_date = "Database error!"; + $post_category = "Database error!"; + } + } + function shortText($string,$lenght) { diff --git a/themes/jumbotron/index.php b/themes/jumbotron/index.php @@ -16,6 +16,7 @@ $error = "0"; $empty_id = empty($_GET["id"]); $empty_category = empty($_GET["category"]); + $empty_author = empty($_GET["author"]); if (!$empty_id){ $id = $_GET["id"]; }else{ @@ -26,6 +27,11 @@ }else{ $category = ""; } + if (!$empty_author){ + $author = $_GET["author"]; + }else{ + $author = ""; + } include('../../core/config/variables.config.php'); ################ @@ -141,7 +147,7 @@ <div class="container"> <?php $x = 1; - if ($empty_id && $empty_category){ + if ($empty_id && $empty_category && $empty_author){ #$id = 1; include('../../core/backend/blog/posts.php'); while ($x < $post_id_clean+1){ @@ -152,7 +158,7 @@ </h1> <div> <h4> - <span class='theauthor'><a href='#' rel='author'>$post_author</a></span> | + <span class='theauthor'><a href='index.php?author=$post_author' rel='author'>$post_author</a></span> | <time>$post_date</time> | <span class='thecategory'><a href='index.php?category=$post_category' rel='category tag'>$post_category</a></span></br> </h4> @@ -182,7 +188,7 @@ </h1> <div> <h4> - <span class='theauthor'><a href='#' rel='author'>$post_author</a></span> | + <span class='theauthor'><a href='index.php?author=$post_author' rel='author'>$post_author</a></span> | <time>$post_date</time> | <span class='thecategory'><a href='index.php?category=$post_category' rel='category tag'>$post_category</a></span></br> </h4> @@ -201,24 +207,55 @@ next_id_category(); } }else{ - include('../../core/backend/blog/posts.php'); - echo " - <h1> - <a href='index.php?id=$id' rel='bookmark'> $post_title </a> - </h1> - <div> - <h4> - <span class='theauthor'><a href='#' rel='author'>$post_author</a></span> | - <time>$post_date</time> | - <span class='thecategory'><a href='index.php?category=$post_category' rel='category tag'>$post_category</a></span></br> - </h4> - </div> - <div> - <p> - $post_text</br> - </p> - </div> - "; + if ($author){ + $id = 1; + include('../../core/backend/blog/posts.php'); + while ($x < $author_id_clean+1){ + include('../../core/config/connect.db.inc.php'); + echo " + <h1> + <a href='index.php?id=$id' rel='bookmark'> $post_title </a> + </h1> + <div> + <h4> + <span class='theauthor'><a href='index.php?author=$post_author' rel='author'>$post_author</a></span> | + <time>$post_date</time> | + <span class='thecategory'><a href='index.php?category=$post_category' rel='category tag'>$post_category</a></span></br> + </h4> + </div> + <div> + <p> + $post_text_short</br> + </p> + </div> + <p> + <a class='btn btn-primary btn-lg' href='index.php?id=$id' role='button'>$name_more &raquo;</a> + </p> + "; + $x = $x+1; + $id = $id+1; + next_id_author(); + } + }else{ + include('../../core/backend/blog/posts.php'); + echo " + <h1> + <a href='index.php?id=$id' rel='bookmark'> $post_title </a> + </h1> + <div> + <h4> + <span class='theauthor'><a href='index.php?author=$post_author' rel='author'>$post_author</a></span> | + <time>$post_date</time> | + <span class='thecategory'><a href='index.php?category=$post_category' rel='category tag'>$post_category</a></span></br> + </h4> + </div> + <div> + <p> + $post_text</br> + </p> + </div> + "; + } } } ?>