Tabbed Widget Part Two

Tabbed Widget

Previously I wrote of my frustrations and desire to figure out tabbed widgets: Tabbed Widgets Part One. Funny that I had to struggle to find a way to display the code in a way that would not be parsed and or run by the blog engine. Hence the delay. However I found a plugin that suited me: iG:Syntax Hiliter. Don't let the age of the plugin worry you, I run WordPress 2.9.2 - at the time or writing this - and it works.
You'll also notice that I have extended the use of the tabs into the post footer where I show:

  • Author Information (yes you can guest post)
  • Related Posts
  • Top Posts in this category

This is how I did it

Script

  • Download the idTabs JavaScript file; currently there is version 2.2 and beta version 3.0.
  • Extract the script/s into your theme's js folder

Add the call to the scripts in your Theme's header.php file:

JavaScript:
  1. <script src=<?php bloginfo('template_directory'); ?>"></script>

Make sure that there is a call to load the jQuery core as well

either

JavaScript:
  1. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

or

JavaScript:
  1. <script src='<?php bloginfo('template_directory'); ?>' type="text/javascript"></script>

PHP Calls

  • Obtain the plugins necessary to generate the lists that you may want to generate. The two lists I have are:
    • Top Posts. I made use of Popularity Contest, it has some great examples and the plugin itself produces some great information that can improve your blog.
    • Categories. I used the built in function wp_list_categories to list the categories without the heading:
      PHP:
      1. <?php wp_list_categories( 'orderby=name&amp;title_li=' ); ?>

      Check out WordPress Codex for how you can further make use of wp_list_categories.

    • For random posts, I used the build in call:
      PHP:
      1. <?php random_posts(); ?>

If you are wanting to add this as a widget and are also wanting to make use of php functions to generate lists then you will need to make use of a widget that can execute php code. The one that worked for me was phpCode. Add this widget to your sidebar.
HTML/PHP Code
Add the code that you need:

HTML:
  1. <div class="idTabs">
  2. <div class="menu">
  3.   <ul>
  4.     <li><a class="selected" href="#topposts">Top Posts</a></li>
  5.     <li><a  href="#categories">Categories</a></li>
  6.     <li><a href="#random">Random</a></li>
  7.   </ul>
  8. </div>
  9. <div class="items">
  10.   <div id="topposts"><?php akpc_most_popular() ?>
  11. </div>
  12.   <div id="categories"><?php wp_list_categories( 'orderby=name&title_li=' ); ?></div>
  13. <div id="random"><?php random_posts(); ?></div>
  14. </div>
  15. </div>

CSS

CSS:
  1. .idTabs { margin:0;padding:0 0 10px 0;}
  2. .idTabs ul { background:#000; padding:5px 0 0 5px; float:leftwidth:302px; }
  3. .idTabs li { list-style:none; /*Try deleting this float*/ float:left; padding:0;}
  4. .items li { list-style-type:square;}
  5. .idTabs a { display:block; background:#000; color:snow; padding: 0 5px 0 5px!important; font:bold 12pt Arial; text-decoration:none; }
  6. .items>div a { display:block; background:222; color:snow; padding: 2px 0 0 5px!important; font:10pt Arial; text-decoration:none; width:288px;border:none;}
  7. .menu>div a { display:block; background:222; color:snow; padding: 2px 0 0 5px!important; font:10pt Arial; text-decoration:none; width:288px;border:none;}
  8. .menu>div a:hover { display:block; background:#333; color:snow; padding: 2px 0 0 5px!important; font:10pt Arial; width:288px;border:none;text-decoration:underline;}
  9. .idTabs a.selected { background:#FFF!important; color:#000!important; padding: 0 5px 0 5px!important}
  10. .items>div { display:none; float:left; margin:0.1em 0 0 0.5em; color:#fff; background: #fff; margin: 0 0 15px; padding:5px;width:100%;}
  11. .items>div a:hover{ color:#eee; background: #333;}
  12. .items {padding: 0 0 5px 0;}

Did this help you? Please let your peeps know and tell me what you think or if you have any other suggestions.
Also this was quite a learning curve for me. Let me know what you have learned lately
.

  • 6 Responses to “Tabbed Widget Part Two”

    1. Nate Pointer March 14, 2010 at 11:33 pm #

      Thanks for this post. I was having the same problem with WordPress and adding tabs. Very easy to setup and works great. Now I just have to style it to match the rest of my site. Just purchased StandardTheme and have been working on a redesign. Thanks again!
      Nate Pointer´s last blog ..Sample Post My ComLuv Profile

    2. Nate Pointer March 14, 2010 at 11:46 pm #

      Thanks for this post. I was having the same problem with WordPress and adding tabs. Very easy to setup and works great. Now I just have to style it to match the rest of my site. Just purchased StandardTheme and have been working on a redesign. Thanks again!

    Trackbacks/Pingbacks:

    1. faith-based film - March 12, 2010

      Tabbed Widget Part Two: Previously I wrote of my frustrations and desire to figure out tabbed widge... http://bit.ly/9qO4lI
      (@phillipgibb)

    2. phillipgibb - March 13, 2010

      My Blog Post Tabbed Widget Part Two - Previously I wrote of my frustrations and desire to figure out tabbed widgets... http://ow.ly/16N1uS

    3. Алексей - March 17, 2010

      ...

      Хм ...

    Leave a Reply:

    Gravatar Image

    XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    CommentLuv Enabled

    This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

    Spam Protection by WP-SpamFree


    Comment links Optimised by hobo.