Archive for January, 2006

WordPress Fix: Allow Comments on Pages

Monday, January 30th, 2006

WordPress Plugin

By default WordPress has the functionality in place for comments to be added to posts. However, out of the box there seems to be no ability to add comments to Pages created in WordPress – despite the fact that one of the settings when editing a Page is "Allow Comments".

The problem is not so much with WordPress itself as with the "Theme" or template you are using. A quick fix to one of the pages in the default theme will get you up and running.

How it is done

You will need to be able to edit the files in the default theme – either via the WordPress Admin (files must be writeable), or via FTP.

Open up the file called "page.php" which sits in the "wp-content/themes/default/" directory. Then replace it's contents with the following code and save/upload the file:

<?php get_header(); ?>
    <div id="content" class="narrowcolumn">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
            <h2><?php the_title(); ?></h2>
            <div class="entrytext">
('<p class="serif">Read the rest of this page ╗</p>');
link_pages('<p><strong>Pages:</strong> ''</p>''number'); 
endwhile; endif;

        //Allow Admins to edit this page 
edit_post_link('Edit this entry.''<p>''</p>');

        //Fix to allow comments to be added to Pages

Of course, this example presumes you are working with the "default" theme. If you would like to fix another theme then the actual code that fixes everything is this single line:

<?php comments_template(); ?>

I hope this helps somebody – I know it would have saved me a few minutes…

My First WordPress Plugin: Visual.Syntax

Monday, January 30th, 2006

WordPress PluginCurrent Version: 2.01

"Visual.Syntax" is a plugin for WordPress that preserves source code formatting and provides full syntax highlighting. It is compatible with WordPress 1.5/2.0 and PHP 4/5. Update: Tested in WordPress 2.9 – no issues.

Unlike other code plugins Visual.Syntax offers highlighting of HTML and CSS in addition to PHP. I have customized the highlighting to match Dreamweaver's syntax coloring as much as possible, as well as my own preferences. Visual.Syntax will also force any CSS into a readable pre-defined format.


Follow these basic steps:

  • Download this file: (5kb)
  • Unzip the file on your computer.
  • Upload the complete folder "Visual.Syntax" to your WordPress plugins directory (usually found in "wp-content/plugins")
  • Login to WordPress and go to the Plugins module
  • Find the line that says "Visual.Syntax" and click "Activate"

Note: This plugin is not compatible with the WYSIWYG Visual Editor that comes with WordPress. You will have to be using the old-style HTML editor (textarea) if you want to highlight your source code.

How to Use

It is quite simple – simply wrap your PHP and HTML code in <code>text</code> and your CSS in <css>test</css>.

Each block of code is wrapped in a DIV with a CSS class of "VisualSyntax" so that you can customize the appearance of the code block. For example see the grey background on the code blocks shown below. Here is the CSS I am using:

.VisualSyntax {
    background-color: #F9F9F9;
    border: 1px solid #F0F0F0;
    font-family: "Courier New",Courier,mono;
    font-size: 12px;
    line-height: 1.5em;
    margin: 0;
    overflow: auto;
    padding: 5px 5px 0;
    white-space: nowrap;
    width: 98%;

Output Examples

PHP Example:

//output "Hello.World" to the browser
$text "Hello.World";

HTML Example:

<p><img src="/images/wordpress.png"></p>
<p>This is an example of 
   <a href="/weblog/visual.syntax/">Visual.Syntax</a> 
   highlighting HTML.</p>

CSS Example:

@import "stylesheet.css";

body {
    margin: 0px;
    padding: 0px;

a {
    color: #0000FF;
    text-decoration: none;

Support / Feedback

I welcome any comments, feedback, suggestions, or bug reports. Please either use my Contact Form or leave a comment.


2006-01-30 - Fixed problem with smart quotes. Now version 2.01.
2006-01-30 - Released version 2.0 to WordPress Users.

Sage: The Firefox Atom & RSS Feed Reader

Saturday, January 28th, 2006

Sage Screenshot

If you are like me you are still figuring out the best way to manage your favorite RSS feeds. Today I discovered Sage, a Firefox extension that lets you read your RSS and Atom feeds inside your browser – which makes sense to me. It is very simple to use and is not cluttered with features I don't need. Here are some of the features I like about it:

  • Press "Alt-S" to toggle Sage on/off in the Sidebar.
  • Press the magnifying glass icon to auto-discover feeds on the current page.
  • Manage your list of feeds exactly like managing your bookmarks – you can sort them any way you like, rename them and place a seperator between them.
  • This is probably my favorite feature – Sage very quickly renders a column formatted list of the posts to read. See the image posted above for an example. The look and feel of this layout can be customised via CSS – in fact there are additional styles already created for you to download.

Catching up on the latest via RSS is now a logical extension of my browsing experience thanks to Sage

Should It Open a New Window?

Saturday, January 28th, 2006

One question I have been asking myself when writing this blog is – should external links in my blog open a new window by default, or should it stay in the current window? What is considered "best practice" nowadays? So I decided to do a bit of research. As usual when it comes to such topics the opinions are many and varied, and everyone thinks they are right. So I decided to share with the world my conclusions. :)

I have decided that it is best practice to not open new windows to external sites by default. Why?

  • New windows popping up can confuse inexperienced surfers who are used to the safety of the "Back" button. A new window does not retain the browser history of previous windows, thus rendering the Back button useless.
  • Experienced surfers know how to open new windows or tabs – let them choose. Tip: In Internet Explorer and Firefox hold down the "shift" key when clicking a link to open it in a new Window, or in Firefox use the "ctrl" key to open in a new Tab.

  • New windows opening up are a big problem for the visually impaired whose speech-to-text software may not have been warned of the window change, or they have missed hearing the warning that a new window was opened.

Of course, there are always exceptions to the rule. In some situations opening a new browser window is the logical thing to do – but not for every link by default.

If you do…

When/if you do want to open a new Window keep in mind that the target attribute of the <a> tag is deprecated, and will prevent your pages from validating in HTML 4.01 Strict, XHTML 1.0 Strict, or any future version. There are a number of alternative methods around – most of them using JavaScript. Here is the method I recommend:

<a href="" onclick="; return false;">
  A Test Link

Here is a sample link using this code.

Why is this recommended method? It achieves our objective of opening a new window, but it also:

  • Preserves the href element for Search Engines
  • Users who want control can still right-click
  • The link can still be Bookmarked or added to the browser Favorites
  • Your code will validate


So … future external links on this blog will not open a new window by default. And on the odd occasion it is a good idea, I will use the method outlined above.

If you have any thoughts on this topic I would love to hear them…

The Future of HTML: XHTML 2.0

Saturday, January 28th, 2006


XHTML 2.0 is the W3C's effort to fix inherent problems with HTML and to meet the growing requirements of web-based solutions. XHTML 2.0 takes the move toward XML to the next level and will try to acheive the following design goals:

  • Use XML as much as possible: Where a language feature already exists in XML, don't duplicate or reinvent it.
  • Structure over presentation: Thanks to CSS stylesheets, you no longer need explicitly presentational tags in HTML.
  • Make HTML easier to write: Remove some of the needless idiosyncrasies of HTML.
  • More accessibility, device independence: Make as few assumptions as possible about the way a document will be read.
  • Improved internationalization.
  • Better forms: Long overdue improvements are required!
  • Reduce the need for scripting: Include typical scripting usages in HTML itself.
  • Better semantics: Make it easier to integrate HTML with semantic Web applications.

Of particular interest to me is the goal of XHTML 2.0 to provide a declarative format for specifying user interfaces in a similar way to Mozilla's XUL or Microsoft's XAML. W3C will also define XBL2, a declarative language that provides a binding between custom markup and existing technologies. XBL2 will essentially give programmers a way to write new widgets for Web applications.

If you want to prepare yourself for the future an article on IBM Developer Works suggests the following:

  • Get serious about using CSS, and try to remove all presentational markup.
  • Think about how you can deploy microformats in your pages. (Microformats are a way to make human-readable elements in Web pages carry semantics that computers can interpret too. They are a bridge between today's HTML-based ad-hoc semantics and tomorrow's RDF-compatible XHTML 2.0 metadata.)
  • If you've not done so already, get experience with XHTML 1.0.
  • Experiment with the X-Smiles browser, an experimental platform with early support for many of the W3C's new client technologies such as XHTML 2.0, SVG, XForms, and SMIL 2.0 Basic capabilities.
  • If you create new client systems based on XHTML-like functionality, seriously consider using XHTML 2.0 as your starting point.

XHTML 2.0 is not likely to become a W3C Recommendation until 2007, according to W3C HTML Working Group Roadmap. Now is the time to start reading and experimenting with XHTML 2.0 – and prepare for the future!

For the full article from IBM Developer Works click here.

PHP and XUL in the Enterprise:

Friday, January 27th, 2006 - using PHP and XUL

I found an interesting article on PHP and XUL being used to power – a leading information website in France. It is an excellent example of PHP and XUL being used at Enterprise level – and a nice case study to read about if you use these tools.

The site receives around 68,000 subscriptions monthly and an average of 70,000,000 (million) page views. Not bad. The entire website is powered by PHP, and they use XUL/PHP combined to power their Content Management System. The following statements highlight the benefits from using these technologies:

The system is now powerful, using 4 Linux servers at 20% cpu while it was using 4 Sun servers at 70% cpu before. Development time has been divided by 2 and number of bugs by 3, in addition to the excellent documentation and support available in both XUL and PHP Communities.

You can read the full article here.

FireBug: The Ultimate JavaScript, DHTML, AJAX Debugger

Tuesday, January 24th, 2006

I only just wrote an article on Console├é┬▓ and I found something better – FireBug. FireBug is a new tool for Firefox that aids with debugging Javascript, DHTML, and Ajax. It is like a combination of the Javascript Console, DOM Inspector, and a command line Javascript interpreter.

FireBug is fairly simple – it adds a console to the bottom of every web page in Firefox. It enables the following features:

  • Mouse-over DOM Elements on the page
  • Type in JS expressions into the command line for execution
  • Inspect AJAX (XMLHttpRequest) responses as text or XML
  • Only show errors for the current page – previous data is cleared
  • Display JavaScript, CSS or XML Errors
  • Show a red dot in the Status Bar to indicate errors on the current page
  • Set preferences on what errors you want to see

If you are a developer you can even get your page to write directly to Firebug – instead of using "alert()" or other methods for debugging. There is even a tutorial on how to do this.

Yup, you have to install this one

Handy Extensions for Firefox

Tuesday, January 24th, 2006

Every now and again you come across a little tool that becomes a part of your everyday life. Here are two recently discovered extensions for Firefox that definitely fall into that category:

ViewMyCurrency allows you to view a web page with any dollar amounts automatically converted to your chosen currency – and using live exchange rates. For example a page might show $99 in USD – ViewMyCurrency will make the page display $145 ($99) for NZD. What's more you can toggle it on and off while looking at the page.

Apple Expose for Firefox. foXpose lets you view all the open tabs in the browser by clicking F8 or the little icon in the bottom left of your status bar. It only runs in Firefox 1.5.

If you use Firefox then take a look at these great extensions – and if you have others to share then please leave a comment with a link…

Useful AJAX Based Tools

Wednesday, January 18th, 2006

This week I discovered three very useful tools built in AJAX. Here they are for my own future reference – and maybe you will enjoy these as well:

      WizLite – this very nifty tool allows users to collaboratively highlight important passages on a page on the Internet. Users can attach notes to their selections. Wizlite is activated by a bookmarklet or Firefox toolbar extension.
      Rex-V – a regular expression evaluator. Evaluates PHP PCRE, PHP Posix and JavaScript regular expressions. It also includes quick reference help which is very useful.
      phpFunctions – an AJAX interface to quickly look up a function and then load the details from

    Are there any similar tools out there that you would like to share?

Are you an Expert or Novice Programmer?

Saturday, January 14th, 2006

Researchers (Hayes, Bloom) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. So … how long have you been programming? How would you rank your ability? Check out this interesting post to see one authors view of how to rank yourself or others. Could be interesting to think about if you employ programmers as well…