Archive for the ‘wordpress’ Tag

_SESSION fun #1: Visit History   Leave a comment

Practically SESSIONS have infinite serious uses. But, being serious is one part, being ‘interesting’ is more serious than that. Usually people won’t agree to include thee types of weird sections in their pages, since your browser will always decolorize the visited links! I thought it might get user attraction and they will pay attention to see their progress in finishing up reading web site contents. Anyway this is fun and those who have just started understanding SESSIONS; this will be a good part to play with … hopes they are also not in the lat minute to production!

The code does this:

  •  Tracks the current and past posts
  • Displays a list in the last visited order

Funny part, it will never show if you ever been here before, simply removes the current page from visited pages list, so visited will never know that they have been her once!

single.php


<?php
// Place this in the single.php

 get_header();
$visited_pages = $_SESSION['vpages'];
 $last_visited_page = $_SESSION['lpage'];

 while ( have_posts() ) : the_post();
   $the_title = get_the_title();
	echo "<h1>".$the_title."</h1>";
	echo "<h2>".get_the_excerpt()."</h2>";
	the_content();

	 if($last_visited_page != $the_title){
    	  if($visited_pages):
     	    $already_pages = explode("~", $visited_pages);
     	    $visited_pages = $last_visited_page;
     	    foreach ($already_pages as $item){
        	    if($the_title != $item && $last_visited_page != $item) :
        	      $visited_pages .= "~".$item;
        	    endif;
    	    }
    	 else:
    	   $visited_pages = $last_visited_page;
    	 endif;
endwhile;	 }
$_SESSION['vpages']= $visited_pages;
$_SESSION['lpage'] = $last_visited_page;

if($visited_pages)
  echo "<BR>Visited Pages:<ol> ". preg_replace("/([^~]+)~*/", "<li>$1</li>",$visited_pages) . "</ol>";

get_footer();
?>

Like always I think if you like this one, try to build one pie chart that shows how many posts are read and how many are left! You can use the Google Chart API to build the graph.

Advertisements

Posted February 4, 2012 by jsusmer in Lesson, mind waves

Tagged with ,

An apology   Leave a comment

I know it’s too late to tell this, but, now its light and I could see it clearer and the fog created by those foolish developers have moved. I have set my sail high and am running freely in the WordPress landscapes like a small child with his favorite toy in his hand.

I’m feeling it’s power that will push my abilities to the heights that will enable easy web development. I’m planning to push WP to it limits and some day will post all what I have experienced during this!

Sorry WP, I misunderstood you these years!! Better late than never 🙂

Posted January 21, 2012 by jsusmer in mind waves

Tagged with