Archive for April, 2012

Mental Model Diagrams (Cartoon)


  

We tend to carefully create our HTML and CSS, and meticulously place every pixel to our designs. We plan exactly where our content should be placed on a particular site. Among many other decisions we need to make, we always keep in mind to craft a great experience for all our users. But how do we know what our users really want?

One way is to understand the motivations that drive users in general. A mental model diagram can be created to do just that—to dive deeper and discover what users are trying to accomplish, and then create solutions that match.

In this comic, Indi and Brad introduce mental model diagrams to us and how we can use them to build better websites. You can also view a larger version of the comic here.

Mental Model Diagrams

Feel free to share your thoughts on mental model diagrams in the comments section below.

(il)


© Indi Young and Brad Colbow for Smashing Magazine, 2012.


A Collection of Beautiful Joomla Templates


  

Originally a fork of Mambo, Joomla has grown into the second most popular Content Management System (CMS) on the web behind WordPress. In January 2012 Joomla was upgraded from 1.7 to version 2.5. It brought a lot of great new features such as notifications for easier updates, multi database support and improved search functionality.

Today we would like to show you a collection of 30 beautiful Joomla templates that showcase what this powerful and popular script can do.

The Collection

1. Momentum
Regular License: $50

A stylish template that comes with 6 preset styles, 78 module positions and 58 module variations. It also includes a colour chooser and a background slideshow option. The drop down navigation menu at the top of the page looks beautiful and it includes a lot of pre defined typography settings build in (most of which can be used using shortcodes).

Momentum Joomla Template

Info & Download | Demo

2. Ionosphere
Regular License: $50

Ionosphere is a versatile template that comes with 12 colour schemes. It has a whopping 84 module positions and support for viewing on iPhones and Android devices. RocketTheme exclusives such as the Fusion Menu and RokSprocket extension for styling are also included.

Ionosphere Joomla Template

Info & Download | Demo

3. Modulus
Regular License: $50

Another versatile theme from RocketTheme that comes with a colour chooser, 12 colour schemes and 68 module positions to choose from. 16 unique RocketTheme extensions are also included such as the comment extension RokComments, content rotator RokNewsFlash and Twitter module RokTwittie.

Modulus Joomla Template

Info & Download | Demo

4. MissionControl
FREE

A free admin template that was developed for Joomla 2.5 to make administrating a Joomla website more user friendly. It’s fast loading and has features such as custom logo uploading, user statistics and an editor switcher.

Mission Control Joomla Template

Info & Download

5. Pixellove
Personal License: €40, Business License: €65, Lifetime License: €99, Developer License: €199,

A beautiful dark blog template that has portfolio options for showcasing your work. A light version of the theme is also included and support for 3rd party extensions such as the K2 component and News Show Pro.

Pixellove Joomla Template

Info & Download | Demo

6. Game Magazine
Personal License: €40, Business License: €65, Lifetime License: €99, Developer License: €199,

Designed for multimedia topics like gaming, movies and music. Game Magazine has a great looking home page slider that can show featured, recent and popular posts. It works with a lot of 3rd party extensions and has beautiful typography as well.

Game Magazine Joomla Template

Info & Download | Demo

7. League News
Personal License: €40, Business License: €65, Lifetime License: €99, Developer License: €199,

A professional looking news portal that was created for sports websites. Developed using HTML5 and the latest Gavern Framework, League News is arguably the best magazine style design available for Joomla at the moment. It includes a news rotator, support for many popular extensions and great social media integration.

League News Joomla Template

Info & Download | Demo

8. Kallos
Regular License: $33

A business style Joomla template that can display content in 1, 2 or 3 columns. There are 17 module positions and 16 advertising positions to choose from and it comes with 5 colour schemes. Fixed and fluid layouts can be used and a layered Photoshop PSD file is included with the template too.

Kallos Joomla Template

Info & Download | Demo

9. Mad Chicken
Regular License: $33

Designed for fast food businesses, Mad Chicken is a simple design that was setup to promote your menu. It comes with two colour schemes: red, orange and yellow and red, green and light brown. Powered by the Gantry Framework, the same framework that is used to power all RocketTheme designs, it includes a colour picker for choosing theme colours and has support for the iPhone and Android devices.

Mad Chicken Joomla Template

Info & Download | Demo

10. Slate
Regular License: $35

A corporate design that comes with 5 pre-defined colour schemes. The home page features a great looking featured slider and content can be displayed using portfolio, gallery and blog templates. It works with JoomShopping Cart so it can be used to build an online store too.

Slate Joomla Template

Info & Download | Demo

11. JTAG TV
Regular License: $40

JTAG TV was designed specifically for movie, video and TV websites and blogs. It works with most video services such as YouTube and Vimeo and includes the latest clips video slider.

JTAG TV Joomla Template

Info & Download | Demo

12. N6
Regular License: $57

A one page template design that comes with 12 colour schemes and a fixed or fluid layout. Designed using the Wright Framework, Transitions between different sections are smooth and the typography used in the design is beautiful.

N6 Joomla Template

Info & Download | Demo

13. Joy
Regular License: $57

A versatile Joomla template that comes with 6 colour schemes. The design is clean and professional looking with box images used throughout the design to promote pages and posts.

Joy Joomla Template

Info & Download | Demo

14. Collective
Regular License: $53

A business design that uses a 960 grid layout. There are 12 module positions to choose from and you can use 1, 2 or 3 column layouts to display your content. 10 colour schemes are included though only the header and link colours are different in each skin.

Collective Joomla Template

Info & Download | Demo

15. Orion
Regular License: $47

A professional corporate style that has a great featured post slider on the home page and 14 module positions. 4 colour schemes are included and it has a cool drop down navigation menu at the top of each page.

Orion Joomla Template

Info & Download | Demo

16. Bensroben
Regular License: $45

A beautiful clean responsive Joomla template that changes the number of posts displayed depending on width of the browser being used. The transition from 2 to 3 to 4 columns is smooth and when a visitor hovers over a post the other post images on the page fade to highlight the post being selected. 8 colour schemes are included as well as a slideshow module and portfolio template.

Bensroben Joomla Template

Info & Download | Demo

17. Meltas
Regular License: $40

A clean minimal Joomla template that is suitable for business, blogs and portfolio websites. The home page features a large featured slider that has 27 animation styles. 7 colour schemes are available and there is a built in testimonial template too.

Meltas Joomla Template

Info & Download | Demo

18. QT
Regular License: $35

A feature rich Gantry Framework powered design that has 11 different types of home page sliders and 65 module positions to choose from. Google web fonts are supported and there are 4 colour schemes included with the template. Alternatively, theme colours can be changed using the colour chooser.

QT Joomla Template

Info & Download | Demo

19. Asareng
Regular License: $40

An elegant template that comes with a number of different dark and light skins (16 variations in total). 4 different home page layouts are included together with a testimonials template. A good choice for a business website, blog or portfolio.

Asareng Joomla Template

Info & Download | Demo

20. Supremacy
Regular License: $35

A creative corporate design that comes with 50 colour variations. The colour variations are quite small though with the dark colour scheme retained at the top of the design and the content area changing colours. There are 11 different versions of the slide that is displayed on the home page (on an iMac no less!) and one or two sidebars can be used on content pages.

Supremacy Joomla Template

Info & Download | Demo

21. James
Regular License: $30

A simple yet stylish personal Joomla template that was created for resumes and simple information websites. Despite the simplicity of the template, it offers 67 different module positions and 36 different layout combinations.

James Joomla Template

Info & Download | Demo

22. JF Chrome
Regular License: $35

JF Chrome is a flexible Joomla template that could be used for businesses, blogs, portfolios and communities. There are two different versions of the beautiful home page slider available, 4 colour variations and 4 menu options. It supports Google fonts too and comes with 40 module positions, a pricing table and custom error pages.

JF Chrome Joomla Template

Info & Download | Demo

23. Technik
Regular License: $40

A futuristic technology template for Joomla that has a gorgeous Javascript based slider on the home page. It comes with 5 colour variations with light and dark backgrounds, 28 module positions and lots of short codes for styling content. A good choice for a business website or tech magazine.

Technik Joomla Template

Info & Download | Demo

24. Superb
Regular License: $40

Superb is a creative Joomla template that comes with 16 colour schemes (8 variations of light and dark). It comes with a beautiful blog template, a 1, 2 or 3 column portfolio template and a 2, 3 or 4 column gallery template. 3 different home page layouts can also be chosen with each layout showing a different sized feature slider.

Superb Joomla Template

Info & Download | Demo

25. Ammon
Regular License: $40

A clean professional looking template that could be used for any kind of website. One of the themes biggest selling points is its 12 different sliders. These allow you to use rotating image backgrounds, a nivo slider or even a video background.

The theme has 70 different module positions and numerous page templates including a blog template, portfolio template, photo gallery and FAQ template. Google fonts are supported as well and there are lots of shortcodes for styling content. You need to check out the theme demo to appreciate the quality of this template.

Ammon Joomla Template

Info & Download | Demo

26. BlackStudios
Regular License: $40

BlackStudios is a dark and clean corporate design that comes with 5 colour variations. It has support for Google fonts, looks great on mobile devices and there are over 60 module positions to choose from.

BackStudios Joomla Template

Info & Download | Demo

27. Aeon
Regular License: $45

A futuristic design that uses an impressive slider on the home page and a smooth drop down navigation menu at the top of the page. It has support for Facebook comments and has great typography for styling your content.

Aeon Joomla Template

Info & Download | Demo

28. AMOS
Regular License: $40

AMOS is a versatile design that lets you use a one page scrolling template for the home page or a regular home page that links to sections as different pages. It includes 7 different sliders, 60 different module positions, 2 different portfolio layouts and lots of unique templates and shortcodes for styling content.

AMOS Joomla Template

Info & Download | Demo

29. Sunrise
Regular License: $40

A clean business template that features a nivo slider on the home page. It comes with a light and dark skin though colours can be customised how you want using the theme style editor. Portfolio, gallery and blog templates are also included with the template.

Sunrise Joomla Template

Info & Download | Demo

30. Depeche
Regular License: €25

Named after the British band Depeche Mode, Depeche is a grungy design that is perfect for blogs. It includes a regular slider, full page slider and article slider and the tableless design allows modules to be collapsed.

Depeche Joomla Template

Info & Download | Demo

That’s a Wrap

We hope you have enjoyed this list of professional Joomla templates. As always, if your favourite design didn’t make the list, please feel free to share it in the comment section.

(rb)


Decoupling HTML From CSS


  

For years, the Web standards community has talked about the separation of concerns. Separate your CSS from your JavaScript from your HTML. We all do that, right? CSS goes into its own file; JavaScript goes in another; HTML is left by itself, nice and clean.

CSS Zen Garden proved that we can alter a design into a myriad of permutations simply by changing the CSS. However, we’ve rarely seen the flip side of this — the side that is more likely to occur in a project: the HTML changes. We modify the HTML and then have to go back and revise any CSS that goes with it.

In this way, we haven’t really separated the two, have we? We have to make our changes in two places.

Exploring Approaches

Over the course of my career, I’ve had the pleasure and privilege to work on hundreds of different websites and Web applications. For the vast majority of these projects, I was the sole developer building out the HTML and CSS. I developed a way of coding websites that worked well for me.

Most recently, I spent two years at Yahoo working on Mail, Messenger, Calendar and other projects. Working on a much larger project with a much larger team was a great experience. A small team of prototypers worked with a larger team of designers to build out all of the HTML and CSS for multiple teams of engineers.

It was the largest-scale project I had worked on in many aspects:

  • Yahoo’s user base is massive. Mail alone has about 300 million users.
  • Hundreds of people spread across multiple teams were working with the HTML and CSS.
  • We were developing a system of components to work across multiple projects.

It was during my time at Yahoo that I began to really examine how I and the team at Yahoo build websites. What pain points did we keep running into, and how could we avoid them?

I looked to see what everyone else was doing. I looked at Nicole Sullivan’s Object-Oriented CSS, Jina Bolton’s presentation on “CSS Workflow� and Natalie Downe’s “Practical, Maintainable CSS,� to name just a few.

I ended up writing my thoughts as a long-form style guide named “Scalable and Modular Architecture for CSS.� That sounds wordy, so you can just call it SMACSS (pronounced “smacks�) for short. It’s a guide that continues to evolve as I refine and expand on ways to approach CSS development.

As a result of this exploration, I’ve noticed that designers (including me) traditionally write CSS that is deeply tied to the HTML that it is designed to style. How do we begin to decouple the two for more flexible development with less refactoring?

In other words, how do we avoid throwing !important at everything or falling into selector hell?

Reusing Styles

In the old days, we wrapped font tags and applied background attributes to every HTML element that needed styling. This was, of course, very impractical, and thus CSS was born. CSS enabled us to reuse styles from one part of the page on another.

For example, a navigation menu has a list of items that all look the same. Repeating inline styles on each item wouldn’t be practical. As a result, we begin to see CSS like this:

#nav {
   margin: 0;
   padding: 0;
   list-style: none;
}

#nav li {
   float: left;
}

#nav li a {
   display: block;
   padding: 5px 10px;
   background-color: blue;
}

Sure beats adding float:left to every list item and display:block; padding:5px 10px; to every link. Efficiency, for the win! Just looking at this, you can see the HTML structure that is expected:

<ul id="nav">
   <li><a href="/">Home</a></li>
   <li><a href="/products">Products</a></li>
   <li><a href="/contact">Contact Us</a></li>
</ul>

Now, the client comes back and says, “I want a drop-down menu to appear when the user clicks on ‘Products.’ Give them easy access to each of the pages!� As a result, our HTML changes.

<ul id="nav">
   <li><a href="/">Home</a></li>
   <li><a href="/products">Products</a>
      <ul>
         <li><a href="/products/shoes">Shoes</a></li>
         <li><a href="/products/jackets">Jackets</a></li>
      </ul>
   </li>
   <li><a href="/contact">Contact Us</a></li>
</ul>

We now have a list item within a list item, and links within it. Our menu has a horizontal navigation when the client wants a vertical list, so we add some rules to style the inner list to match what the client wants.

#nav ul {
   margin: 0;
   padding:0;
   list-style:none;
}

#nav li li {
   float: none;
}

#nav li li a {
   padding: 2px;
   background-color: red;
}

Problem solved! Sort of.

Reducing The Depth Of Applicability

Probably the most common problem with CSS is managing specificity. Multiple CSS rules compete in styling a particular element on the page. With our menu, our initial rules were styling the list items and the links in the navigation and the menu. Not good.

By adding more element selectors, we were able to increase specificity and have our menu styles win out over the navigation styles.

However, this can become a game of cat and mouse as a project increases in complexity. Instead, we should be limiting the impact of CSS. Navigation styles should apply to and affect only the elements that pertain to it, and menu styles should apply to and affect only the elements that pertain to it.

I refer to this impact in SMACSS as the “depth of applicability.� It’s the depth at which a particular rule set impacts the elements around it. For example, a style like #nav li a, when given an HTML structure that includes our menus, has a depth of 5: from the ul to the li to the ul to the li to the a.

The deeper the level of applicability, the more impact the styles can have on the HTML and the more tightly coupled the HTML is to the CSS.

The goal of more manageable CSS — especially in larger projects — is to limit the depth of applicability. In other words, write CSS to affect only the elements that we want them to affect.

Child Selectors

One tool for limiting the scope of CSS is the child selector (>). If you no longer have to worry about Internet Explorer 6 (and, thankfully, many of us don’t), then the child selector should be a regular part of your CSS diet.

Child selectors limit the scope of selectors. Going back to our navigation example, we can use the child selector to limit the scope of the navigation so that it does not affect the menu.

#nav {
   margin: 0;
   padding: 0;
   list-style: none;
}

#nav > li {
   float: left;
}

#nav > li > a {
   display: block;
   padding: 5px 10px;
   background-color: blue;
}

For the menu, let’s add a class name to it. This will make it more descriptive and provide a base for the rest of our styles.

.menu {
   margin: 0;
   padding: 0;
   list-style: none
}

.menu > li > a {
   display: block;
   padding: 2px;
   background-color: red;
}

What we’ve done is limited the scope of our CSS and isolated two visual patterns into separate blocks of CSS: one for our navigation list and one for our menu list. We’ve taken a small step towards modularizing our code and a step towards decoupling the HTML from the CSS.

Classifying Code

Limiting the depth of applicability helps to minimize the impact that a style might have on a set of elements much deeper in the HTML. However, the other problem is that as soon as we use an element selector in our CSS, we are depending on that HTML structure never to change. In the case of our navigation and menu, it’s always a list with a bunch of list items, with a link inside each of those. There’s no flexibility to these modules.

Let’s look at an example of something else we see in many designs: a box with a heading and a block of content after it.

<div class="box">
   <h2>Sites I Like</h2>
   <ul>
      <li><a href="http://smashingmagazine.com/">Smashing Magazine</a></li>
      <li><a href="http://smacss.com/">SMACSS</a></li>
   </ul>
</div>

Let’s give it some styles.

.box {
   border: 1px solid #333;
}

.box h2 {
   margin: 0;
   padding: 5px 10px;
   border-bottom: 1px solid #333;
   background-color: #CCC;
}

.box ul {
   margin: 10px;
}

The client comes back and says, “That box is great, but can you add another one with a little blurb about the website?�

<div class="box">
   <h2>About the Site</h2>
   <p>This is my blog where I talk about only the bestest things in the whole wide world.</p>
</div>

In the previous example, a margin was given to the list to make it line up with the heading above it. With the new code example, we need to give it similar styling.

.box ul, .box p {
   margin: 10px;
}

That’ll do, assuming that the content never changes. However, the point of this exercise is to recognize that websites can and do change. Therefore, we have to be proactive and recognize that there are alternative elements we might want to use.

For greater flexibility, let’s use classes to define the different parts of this module:

.box .hd { }  /* this is our box heading */
.box .bd { }  /* this is our box body */

When applied to the HTML, it looks like this:

<div class="box">
   <h2 class="hd">About the Site</h2>
   <p class="bd">This is my blog where I talk about only the bestest things in the whole wide world.</p>
</div>

Clarifying Intent

Different elements on the page could have a heading and a body. They’re “protected� in that they’re a child selector of box. But this isn’t always as evident when we’re looking at the HTML. We should clarify that these particular hd and bd classes are for the box module.

.box .box-hd {}
.box .box-bd {}

With this improved naming convention, we don’t need to combine the selectors anymore in an attempt to namespace our CSS. Our final CSS looks like this:

.box {
border: 1px solid #333;
}

.box-hd {
margin: 0;
padding: 5px 10px;
border-bottom: 1px solid #333;
background-color: #CCC;
}

.box-bd {
   margin: 10px;
}

The bonus of this is that each of these rules affects only a single element: the element that the class is applied to. Our CSS is easier to read and easier to debug, and it’s clear what belongs to what and what it does.

It’s All Coming Undone

We’ve just seen two ways to decouple HTML from CSS:

  1. Using child selectors,
  2. Using class selectors.

In addition, we’ve seen how naming conventions allow for clearer, faster, simpler and more understandable code.

These are just a couple of the concepts that I cover in “Scalable and Modular Architecture for CSS,� and I invite you to read more.

Postscript

In addition to the resources linked to above, you may wish to look into BEM, an alternative approach to and framework for building maintainable CSS. Mark Otto has also been documenting the development of Twitter Bootstrap, including the recent article “Stop the Cascade,� which similarly discusses the need to limit the scope of styles.

(al) (il)


© Jonathan Snook for Smashing Magazine, 2012.


Random Redirection In WordPress


  

If you run an online magazine, most of your readers will never go through your archive, even if you design a neat archive page. It’s not you; it’s just that going through archives is not very popular these days. So, how do you actually make readers dig in without forcing them? How do you invite them to (re)read in a way that’s not boring? How do you make your WordPress magazine more interactive?

Have you tried random redirection?

Call it recycling if you like, but random redirection doesn’t have to be about retreading familiar territory. Through random redirection, you offer readers a chance to hop randomly through your posts and discover content that they somehow missed.

The concept really is simple. All you have to do is create a hyperlink — named, say, “Random articleâ€� — that when clicked will redirect the reader to a randomly pulled article.

WordPress supports random redirection out of the box, but it’s not very obvious. All of the required functions are in the core, but they’re not bound in any common workflow. For instance, generating a “Random article� link in the main menu simply by checking a box in the administration section is not possible.

To implement random redirection in WordPress, you will usually need to work with the following three things:

  • A page to process the redirection,
  • A query to pick a post from the database,
  • Some sort of mechanism to initiate the redirection.

Of course, many of you might want to use a plugin. That’s absolutely fine, as long as you don’t need any more features than what it offers.

You would probably come across Matt Mullenweg’s Random Redirect plugin first. Then you would probably try Random Redirect 2, which expands on that.

Instead, today I’ll guide you through a custom implementation that I use. It’s not the “right� way to implement random redirection; it’s just one plugin-less solution to start with and build on.

We’ll be working with the three things mentioned in the list further up. Let’s go into the concept in detail.

The Simple Solution

We’ll be implementing random redirection through a WordPress page, which we’ll simply call “Random.� Creating this new page in the admin section will be the last step we take, though. Why? Because we don’t want to make the redirection page accessible before it’s been fully implemented.

According to the WordPress template hierarchy, if you create a page template file named page-random.php, whenever a user loads the page assigned to the slug random, it will load through the page-random.php template. This is a well-known benefit of WordPress and is also useful for our random redirection.

The page-random.php page template will not include the usual calls for loading the header, sidebar and footer templates, because our “Random� page won’t generate any visible output for the user; it will simply jump (that is, redirect) to a randomly chosen article. Because we need to make only one request from the database (to select one random article to redirect to), we will make only one call to the get_posts() function in the template, and we’ll use a foreach loop to process the output.

The get_posts() function receives only two arguments as its input, with which we’re specifying that we want to fetch only one post randomly. The orderby argument set to rand is what enables randomization in WordPress. We don’t need to specify the post_type because it’s already set to post by default for get_posts(). We also don’t need to specify the post_status because it defaults to publish, which is exactly what we need.

// source code from page-random.php

// Random Redirection Page Template

// set arguments for get_posts()
$args = array(
    'numberposts' => 1,
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = get_posts ( $args );

// process the database request through a foreach loop
foreach ( $my_random_post as $post ) {
  // redirect the user to the random post
  wp_redirect ( get_permalink ( $post->ID ) );
  exit;
}

So, we first save the data from get_posts() into a variable and then process it through the foreach loop. The magic happens in the foreach loop, when the redirection is initiated through the wp_redirect() function, which has the post’s permalink as its input.

random-redirection-wordpress-add-random-page
Creating a “Random� page through WordPress’ administration interface

Now the only thing we need to do is go to WordPress’s administration section, create a blank new page with the slug random, and publish it. Then, when you visit http://www.mywebsite.com/random/, you will be automatically redirected to a random article.

random-redirection-wordpress-add-random-page-main-menu
Adding a link to the “Random� page in the main menu.

We can now add a link in the main menu to make the page easily accessible.

Using WP_Query Instead

The implementation above can easily be adapted to directly use the WP_Query class, instead of the get_posts() function.

// source code from page-random.php implemented through WP_Query

// Random Redirection Page Template

// set arguments for WP_Query()
$args = array(
    'posts_per_page' => 1,
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

The main benefit of using WP_Query is that it can accept more arguments than the get_posts() function, thus offering more flexibility when you’re building specific queries.

A Few More Examples

With both get_posts() and WP_Query, we can be very specific and implement random redirection for posts of custom types or posts that belong to particular categories.

For example, we could make WordPress redirect to articles published only in the “Travel� category:

// set arguments for WP_Query()
$args = array(
    'category_name' => 'travel', // remember, we are using category slug here
    'posts_per_page' => 1,
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

Or we could redirect to posts from all categories except “Uncategorized�:

// set arguments for WP_Query()
$args = array(
    'category__not_in' => array(1), // id of the category to be excluded
    'posts_per_page' => 1,
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

How about limiting randomization to posts published in 2011?

// set arguments for WP_Query()
$args = array(
    'posts_per_page' => 1,
    'year' => '2011',
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

Maybe even add filtering by custom field? Let’s limit random redirection to posts that have a custom field with the value strawberry assigned.

// set arguments for WP_Query()
$args = array(
    'posts_per_page' => 1,
    'meta_value' => 'strawberry',
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

The example above could easily be transformed to limit random redirection to posts that have the custom field long_description assigned. Remember, our only condition here is for the post to have the custom field assigned. It doesn’t matter what the value of the long_description custom field is.

// set arguments for WP_Query()
$args = array(
    'posts_per_page' => 1,
    'meta_key' => 'long_description',
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

Instead of posts, we could also implement random redirection for pages:

// set arguments for WP_Query()
$args = array(
    'post_type' => 'page',
    'posts_per_page' => 1,
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

We could even create random redirection for custom post types:

// set arguments for WP_Query()
$args = array(
    'post_type' => 'my-custom-post-type',
    'posts_per_page' => 1,
    'orderby' => 'rand'
);

// get a random post from the database
$my_random_post = new WP_Query ( $args );

// process the database request through WP_Query
while ( $my_random_post->have_posts () ) {
  $my_random_post->the_post ();
  // redirect the user to the random post
  wp_redirect ( get_permalink () );
  exit;
}

As you can see from these examples, we can add a random redirection link to a WordPress website with just a few lines of code. Nothing complicated, nothing too advanced.

random-redirection-wordpress-wikipedia-wikihow

If random redirection still doesn’t make sense to you, hop on over to Wikipedia and WikiHow and see how their links to random articles work.

Play The Randomization Game!

Now that you know how easy implementing a random redirection page in WordPress is, you can start planning for your own random output.

All in all, it’s a great feature. Every online magazine should have it. It requires only a single click per request; it’s unpredictable, it’s fun, and it will be useful to your readers.

Further Reading

(al)


© Goce Mitevski for Smashing Magazine, 2012.


Fabulous Phoneography: Gallery of Smartphone Photography


  

What makes a great photograph? Many believe it’s not just the subject of your picture, but even the composition and the style in which you decide to take your picture. Photography, like many arts, is fairly objective–you may find a picture that you love that your best friend absolutely hates. One certain thing about photography, however, is that the technologies and the styling trends are forever changing.

If you have a mobile phone, especially a smartphone, you probably have taken a picture or two. As technology progresses, the features associated with mobile phone pictures greatly increases. With the help of apps like Instagram, Pudding Camera, and others, you’re able to bring a completely new life to your pictures taken on your phone’s camera. This is often referred to as the art of Phoneography (iPhoneography, Droidography, etc.).

Today, we have put together a nice little round-up of some spectacular examples of phoneography being shared around the web. Get familiar with the camera on your phone and start taking fantastic pictures!

Fabulous Phoneography

Jewellery Box by DistortedSmile

Apoca by arvela

Benevolent kidney beans from the future by doctor-a

Boulevard Brewing Company, Kansas City by spooneb

Caught by elizabethunseelie

Coming down by Ray-K

Day 9 by zootnik

Dreams in the Bones by elizabethunseelie

Droiding the ‘Lude 10 by P. Lachaine

Eyes Like Daggers by Sinéad McKeown

Fan Blades by curtfleenor

iPhone – Gropptorp 1 by alexanderlindelof

Hogmany Spark by elizabethunseelie

In a Cloud Sandwich by Sinéad McKeown

Iphonegraphy by MTHH

Rock Bottom by Gerald-Bostock

Isla Canela, Spain by ChihiroArt

Istanbul 2011 by Alharith

Marie Antoinette’s Hideaway by elizabethunseelie

Moment future by arvela

Multiplying by 2zl

Netted by elizabethunseelie

Putting Down Roots by Droidography

Rufus by texasguitarslinger

Snow no05 by dawgama

Spring Snow by Kotryyyna

Spring is Here by contradictionofsorts

Stopped for the Sun by ActiveSlacker

Storm Over Kansas City by spooneb

Suburban Scape by Nakeva

Sunset at Lakewood by spooneb

Sunset v1, South Shore Harbor Bridg by Nakeva

T2 Ladder by xliredbaron02

The Cheetah Next to Me by mb-neo

Thunderous Waves by september28

Times-A-Ticking by XxMoonlit-UchihaxX

Tiny Teen in the Light by Felipa-de-Noailles

Transmission Failure by Sinéad McKeown

Untitled by Hugo Quintero

Winter Wonderland by Xenabaiche

zoonaar by orgildinho

Iphonegraphy by MTHH

(rb)


  •   
  • Copyright © 1996-2010 BlogmyQuery - BMQ. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress