888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

November 11, 2008

If you’re a theme developer you have almost certainly noticed that the WordPress template tag, next_post_link, can be set up in two ways: to link to the next post, or the next post within the same categories as the current post. This attests to an obvious truth, that what a user wants, or expects, to happen on your blog, will change depending on what they are doing. Modes are a basic method of detecting these intentions.

What is a mode?

A mode is actually very simple. As a visitor moves through your site they will do so in a few different ways. They may link from post page to post page, sort by tag, sort by category or run a search. Depending on whether they are browsing, seeking, or searching their needs will differ.

A mode is a change in the way your theme works to try and meet those needs. So your theme may be in search mode, category mode, tag mode, or browse mode, at any one point in time.

What can I do with modes?

In the introduction I mentioned the template tag next_post_link can work in different ways. In category mode you would expect the user to work backwards through the posts in the category they have selected. The same applies for tag mode.

In search mode they may want access to their search results so they can view each one in turn without having to click back, or open new tabs.

In browse mode it may simply be enough to record the posts they have visited so that when they move modes they aren’t presented with the same posts that they have already seen. For example, If they browse through 5 posts before hitting a category page then presenting visited posts in a separate list from the non-visited posts might let find so much more.

What you do and how you do it is up to you, but there is ample room for you to be imaginative, and to surprise your visitors with the excellent new functionality that is available.

How do I implement modes?

How simple or complex you want your mode switch to be is up to you. At its most simplest all you need do is check the page the users is on and, if that page meets certain conditions, switch mode accordingly.

A very basic mode mode function might look a little like this:

[php]
function get_mode(){
global $post;

$current_mode = array();
$current_mode[0] = ( isset($_SESSION['my_theme_mode']) ) ? $_SESSION['my_theme_mode'] : 'browse';

switch( $current_mode[0] ){
case 'category':
$current_mode[1] = $_SESSION['my_theme_mode_category'];
break;
case 'tag':
$current_mode[1] = $_SESSION['my_theme_mode_tag'];
break;
case 'search':
$current_mode[1] = $_SESSION['my_theme_mode_search'];
break;
case 'browse':
$current_mode[1] = $_SESSION['my_theme_mode_browse'];
break;
}

//if is category, do it
if ( is_category()){
$_SESSION['my_theme_mode'] = 'category';
$_SESSION['my_theme_mode_category'] = single_cat_title("", false);
$current_mode[0] = 'category';
$current_mode[1] = single_cat_title("", false);
} elseif ( is_tag()){
$_SESSION['my_theme_mode'] = 'tag';
$_SESSION['my_theme_mode_tag'] = single_tag_title("", false);
$current_mode[0] = 'tag';
$current_mode[1] = single_tag_title("", false);
} elseif ( is_search()){
$_SESSION['my_theme_mode'] = 'search';
$_SESSION['my_theme_mode_search'] = get_search_query();
$current_mode[0] = 'search';
$current_mode[1] = get_search_query();
} elseif ( is_home() ) {
$_SESSION['my_theme_mode'] = 'browse';
$current_mode[0] = 'browse';
}

if ( is_single() ) {
$browse_array = $_SESSION['my_theme_browsed_posts'];
$browse_array[] = $post->ID;
$_SESSION['my_theme_browsed_posts'][] = $browse_array;
}

$current_mode[2] = ( isset($_SESSION['my_theme_browsed_posts']) ) ? $_SESSION['my_theme_browsed_posts'] : array() ;

return $current_mode;

}

A few posts ago I argued that posts shouldn’t be made more flexible, but more intelligent. Modes is one way to kick this off. What kid of changes would you want to see from an intelligent theme?

Wordpress 25 Exif Fields
Wordpress exif plugin?
12 comments
page 230
Adding Settings To Admin Pages
Wordpress addsettingsfield?
3 comments
page 793
Updating Code Snippets Here
Fun wordpress plugins?
no comment
page 1338
Html 5 Gallery
Html5 image gallery?
6 comments
page 1305
How To Add Sidebars To A Theme
How to register two sidebars in wp?
10 comments
page 1053
Post Image The Easy Peasy Way
Wordpress theimage?
26 comments
page 1065
Using Your Own Url Shortener
Short url?
4 comments
page 1190
Using Wordpress As A Php Framework
Php framework wordpress?
2 comments
page 335
Html 5 Gallery
Html 5 gallery?
6 comments
page 1305
Wordpress Vs Graffiti
Html5 cms?
8 comments
page 95
Post Image The Easy Peasy Way
Wordpress medium size image link?
26 comments
page 1065
Wordpress Chat
Wordpress chat?
3 comments
page 1308
Html 5 Gallery
Wordpress html5?
6 comments
page 1305
Quick N Dirty Admin Login Screen
Web templte admin login page?
no comment
page 128
Post Image The Easy Peasy Way
Wp get url functions?
26 comments
page 1065
Html 5 Gallery
Wordpress html5 theme?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress get first image attached to post?
26 comments
page 1065
Html 5 Gallery
Wordpress html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wp automatically insert image based on tags?
26 comments
page 1065
What Wordpress Workflow Needs
Word press workflow?
3 comments
page 1226
Quick N Dirty Admin Login Screen
Login screen css?
no comment
page 128
How To Add Sidebars To A Theme
Wordpress thematic modify sidebars?
10 comments
page 1053
Six Million Ways To Die Choose One
Ways to die without noticing?
14 comments
page 1128
Post Image The Easy Peasy Way
Wordpress theimage?
26 comments
page 1065
How To Add Sidebars To A Theme
How to add a sidebar to a theme?
10 comments
page 1053
Using Your Own Url Shortener
Htaccess tiny url shortner?
4 comments
page 1190
Photoshop Design Framework
Photoshop framework?
3 comments
page 296
Creating Custom Urls
Custom url for wordpress page?
6 comments
page 80
Photoshop Design Framework
Framework in photoshop?
3 comments
page 296
Html 5 Gallery
Wordpress html5?
6 comments
page 1305
Using Your Own Url Shortener
Build your own url shortener?
4 comments
page 1190
My Experience Of Flexx
Cant upload image to flexx wordpress theme?
4 comments
page 1026
Post Image The Easy Peasy Way
Wpget post image?
26 comments
page 1065
  1 query every 1605 seconds, updated 1 seconds ago.
Thursday, 1pm
 __
(__)
   `

 female

Has read with the pleasure, very interesting post, write still, good luck to you!