Wordpress Toggle Category widget set: Difference between revisions

From Bitpost wiki
(New page: I have a <a href="http://news.thedigitalmachine.com/category/chatter/">Chatter category</a> on my tech blog that's really just for my own notes-to-self. And sometimes I want to see it, so...)
 
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
I have a <a href="http://news.thedigitalmachine.com/category/chatter/">Chatter category</a> on my tech blog that's really just for my own notes-to-self.  And sometimes I want to see it, sometimes I don't.  And I certainly don't want first-time visitors to have to see it.
== Toggle Category Widget Set ==


The solution I came up with was to provide a persistent toggle that would turn on/off the Chatter content.  It starts "off", but any blog visitor can toggle it at any time.  I've packaged the functionality into a set of Wordpress widgets, available for download [http://thedigitalmachine.com/files/widget_toggle_chatter.php here] as a plugin.


There are three widgets in the plugin: the toggle itself, and two widgets that reflect the toggle state, a category list and a list of recent posts.
[http://thedigitalmachine.com/files/ToggleCategoryWidgets_0_3.zip Download v0.3]


NOTE: Current status:
'''Description'''
* The widgets contain hardcoded settings for the category number.  You'll have to edit the plugin directly until I add widget settings.
I have a [http://news.thedigitalmachine.com/category/chatter/ Chatter category] on my tech blog that's really just for my own notes-to-self.  And sometimes I want to see it, sometimes I don't.  And I certainly don't want first-time visitors to have to see it.
* I have some CSS markup cleanup to do.  You can do it yourself in the plugin if you're faster than me.  :>
 
The solution I came up with was to provide a persistent toggle that would turn on/off the Chatter content.  It starts "off", but any blog visitor can toggle it at any time.  See it in action on my [http://news.thedigitalmachine.com tech blog].
 
I've packaged the functionality into a set of Wordpress widgets, available for download [http://thedigitalmachine.com/files/widget_toggle_chatter.php here] as a plugin.  There are three widgets in the plugin: the toggle itself, and two widgets that reflect the toggle state, a category list and a list of recent posts.
 
'''Current status'''
* The plugin contains a hardcoded setting for the category number (2).  You'll have to edit the plugin directly until I add widget settings.
* The plugin contains hardcoded text for the toggle ("Include chatter").  You'll have to edit the plugin directly until I add widget settings.
* The plugin contains a hardcoded path to the plugins directory (/wp-content/plugins).  Edit as needed until I update.
* The plugin helper contains a hardcoded URL for the cookie (news.thedigitalmachine.com).  Edit as needed until I can figure out an easier way.
* I have some CSS markup cleanup to do in the plugin.  You can do it yourself if you're faster than me.  :>
* You will want to modify your theme's index.php file to reflect the toggle's state.  This is easy, and covered in the instructions.
* You will want to modify your theme's index.php file to reflect the toggle's state.  This is easy, and covered in the instructions.


Instructions:
'''Instructions'''
# Download the plugin and extract the files into your plugins directory.
# Download the plugin and extract the files into your plugins directory.
# Go to your Plugins page and activate the Toggle Chatter plugin.
# Go to your Plugins page and activate the Toggle Chatter plugin.
# Go to your Design -> Widgets page and add the widgets to your sidebar.
# Go to your Design -> Widgets page and add the widgets to your sidebar.
# Update your theme's index.php file as follows.  Right before the loop, add this block of code (changing the category number as needed):
# Update your theme's index.php file as follows.  Right before [http://codex.wordpress.org/The_Loop the loop], add this block of code (changing the category number as needed):


  <?php  
  <?php  

Latest revision as of 14:41, 29 July 2008

Toggle Category Widget Set

Download v0.3

Description I have a Chatter category on my tech blog that's really just for my own notes-to-self. And sometimes I want to see it, sometimes I don't. And I certainly don't want first-time visitors to have to see it.

The solution I came up with was to provide a persistent toggle that would turn on/off the Chatter content. It starts "off", but any blog visitor can toggle it at any time. See it in action on my tech blog.

I've packaged the functionality into a set of Wordpress widgets, available for download here as a plugin. There are three widgets in the plugin: the toggle itself, and two widgets that reflect the toggle state, a category list and a list of recent posts.

Current status

  • The plugin contains a hardcoded setting for the category number (2). You'll have to edit the plugin directly until I add widget settings.
  • The plugin contains hardcoded text for the toggle ("Include chatter"). You'll have to edit the plugin directly until I add widget settings.
  • The plugin contains a hardcoded path to the plugins directory (/wp-content/plugins). Edit as needed until I update.
  • The plugin helper contains a hardcoded URL for the cookie (news.thedigitalmachine.com). Edit as needed until I can figure out an easier way.
  • I have some CSS markup cleanup to do in the plugin. You can do it yourself if you're faster than me.  :>
  • You will want to modify your theme's index.php file to reflect the toggle's state. This is easy, and covered in the instructions.

Instructions

  1. Download the plugin and extract the files into your plugins directory.
  2. Go to your Plugins page and activate the Toggle Chatter plugin.
  3. Go to your Design -> Widgets page and add the widgets to your sidebar.
  4. Update your theme's index.php file as follows. Right before the loop, add this block of code (changing the category number as needed):
<?php 
$include_chatter = $_COOKIE['chatter'];
if (is_home()) 
{ 
    if($include_chatter != 'yes') 
    {
        query_posts($query_string . "&cat=-2"); 
    }
} 
?>