Design Scrapbook: PHP/jQuery Image Flipper

Design Scrapbook allows you to simply scroll through a number of images within a directory. For example, we use it to scroll through a number of screen shots of pretty web designs for design inspiration, user interfaces done by the gurus, and general designs that inspire us. It could also be of use as a stand alone portfolio, image gallery, etc.

It works simply by finding all the images in a directory and allowing you to flip through them without having to reload the page. All you have to do it upload the script, upload your images, and you’re done.

  • Flip between screen shots, photos, or any other images.
  • No configuration what-so-ever, just upload and you’re done.
  • No database required.
  • Handles all popular image types.
  • Zoom in and zoom out.
  • Unlimited number of images.

All that is required is PHP 4.3 and GD Library.

WordPress Breadcrumbs for Pages

Breadcrumbs are very useful navigation tools, especially for sites with multiple levels and more than a dozen pages.  While there are a few breadcrumb navigation plugins for WordPress, sometimes it’s a bit of an overkill when the job can be done with just a few lines of code.

The function below will insert a breadcrumb navigation for the pages in your WP site, and highlight the news/blog page when within that section, etc.

Usage:

  1. Copy the code below into your theme’s functions.php file.  If your theme doesn’t have one, create it.
  2. //breadcrumb function
    function rm_bread_crumbs() {
     global $post;
     $crumbs =     '<p><a href="'.get_option('home').'">Home</a>';
    
     //if the page has a parent add title and link of parent
     if($post->post_parent) {
     $crumbs .=     ' &raquo; <a href="'.get_permalink($post->post_parent).'">'.get_the_title($post->post_parent).'</a>';
     }
    
     // if it's not the front page of the site, but isn't the blog either
     if((!is_front_page()) && (is_page())) {
     $crumbs .=    ' &raquo; '.get_the_title($post->ID);
     }
    
     //if it's the news/blog home page or any type of archive
     if((is_home() ||(is_archive()))) {
     $crumbs .=    ' &raquo; '.get_the_title(get_option(page_for_posts));
     }
    
     //if it's a single news/blog post
     if(is_single()) {
     $crumbs .=     ' &raquo; <a href="'.get_permalink(get_option(page_for_posts)).'">'.get_the_title(get_option(page_for_posts)).'</a>';
     $crumbs .=    ' &raquo; '.get_the_title($post->ID);
     }
     $crumbs .=    '</p>'."\n";
     echo $crumbs;
    }
  3. Insert <?php rm_bread_crumbs(); ?> in your theme where ever you’d like the bread crumbs displayed.

Convert an ALL CAPS string to first character capitalized only in PHP

Nothing new to you php gurus, but hope this can help somebody looking for a quick fix – great to filter user inputs in things like addresses, company names, and yes regular ole names. It utilizes PHP’s ucwords() and strtolower():

<? $userInput1 = "MR. CAPITAL LETTERS"; $userInput2 = "mrs. lowercase letters"; ucwords(strtolower($userInput1)); //outputs "Mr. Capital Letters" ucwords(strtolower($userInput2)); //outputs "Mrs. Lowercase Letters" ?>

States HTML Select List w/ PHP Selected Value

I always have trouble finding this, so here it is. The if statement in the checkState() function can be replaced with anything you like to select the option by default…

<?
function checkState($state) {
  if ($row['state'] == $state) {
    echo ' selected="selected"';
  }
}
?>

<select name="state" id="state">
 <option value="--"<? checkState('') ?>>Select...</option>
 <option value="AL"<? checkState('AL'); ?>>Alabama</option>
 <option value="AK"<? checkState('AK'); ?>>Alaska</option>
 <option value="AZ"<? checkState('AZ'); ?>>Arizona</option>
 <option value="AR"<? checkState('AR'); ?>>Arkansas</option>
 <option value="CA"<? checkState('CA'); ?>>California</option>
 <option value="CO"<? checkState('CO'); ?>>Colorado</option>
 <option value="CT"<? checkState('CT'); ?>>Connecticut</option>
 <option value="DE"<? checkState('DE'); ?>>Delaware</option>
 <option value="DC"<? checkState('DC'); ?>>District Of Columbia</option>
 <option value="FL"<? checkState('FL'); ?>>Florida</option>
 <option value="GA"<? checkState('GA'); ?>>Georgia</option>
 <option value="HI"<? checkState('HI'); ?>>Hawaii</option>
 <option value="ID"<? checkState('ID'); ?>>Idaho</option>
 <option value="IL"<? checkState('IL'); ?>>Illinois</option>
 <option value="IN"<? checkState('IN'); ?>>Indiana</option>
 <option value="IA"<? checkState('IA'); ?>>Iowa</option>
 <option value="KS"<? checkState('KS'); ?>>Kansas</option>
 <option value="KY"<? checkState('KY'); ?>>Kentucky</option>
 <option value="LA"<? checkState('LA'); ?>>Louisiana</option>
 <option value="ME"<? checkState('ME'); ?>>Maine</option>
 <option value="MD"<? checkState('MD'); ?>>Maryland</option>
 <option value="MA"<? checkState('MA'); ?>>Massachusetts</option>
 <option value="MI"<? checkState('MI'); ?>>Michigan</option>
 <option value="MN"<? checkState('MN'); ?>>Minnesota</option>
 <option value="MS"<? checkState('MS'); ?>>Mississippi</option>
 <option value="MO"<? checkState('MO'); ?>>Missouri</option>
 <option value="MT"<? checkState('MT'); ?>>Montana</option>
 <option value="NE"<? checkState('NE'); ?>>Nebraska</option>
 <option value="NV"<? checkState('NV'); ?>>Nevada</option>
 <option value="NH"<? checkState('NH'); ?>>New Hampshire</option>
 <option value="NJ"<? checkState('NJ'); ?>>New Jersey</option>
 <option value="NM"<? checkState('NM'); ?>>New Mexico</option>
 <option value="NY"<? checkState('NY'); ?>>New York</option>
 <option value="NC"<? checkState('NC'); ?>>North Carolina</option>
 <option value="ND"<? checkState('ND'); ?>>North Dakota</option>
 <option value="OH"<? checkState('OH'); ?>>Ohio</option>
 <option value="OK"<? checkState('OK'); ?>>Oklahoma</option>
 <option value="OR"<? checkState('OR'); ?>>Oregon</option>
 <option value="PA"<? checkState('PA'); ?>>Pennsylvania</option>
 <option value="RI"<? checkState('RI'); ?>>Rhode Island</option>
 <option value="SC"<? checkState('SC'); ?>>South Carolina</option>
 <option value="SD"<? checkState('SD'); ?>>South Dakota</option>
 <option value="TN"<? checkState('TN'); ?>>Tennessee</option>
 <option value="TX"<? checkState('TX'); ?>>Texas</option>
 <option value="UT"<? checkState('UT'); ?>>Utah</option>
 <option value="VT"<? checkState('VT'); ?>>Vermont</option>
 <option value="VA"<? checkState('VA'); ?>>Virginia</option>
 <option value="WA"<? checkState('WA'); ?>>Washington</option>
 <option value="WV"<? checkState('WV'); ?>>West Virginia</option>
 <option value="WI"<? checkState('WI'); ?>>Wisconsin</option>
 <option value="WY"<? checkState('WY'); ?>>Wyoming</option>
</select>