If you are following me on Twitter you would have seen some junk posts today. Sorry, I was testing a new feature coming in the next release of HashTag - bit.ly support. All you need is an ID and an API key and the HashTag plugin will shorten all the URL's you tweet.

I promise to set up a test account on Twiiter in the future to keep the junk out of your feeds.

Because of the volume of traffic cause by the World Cup, Twitter have decided to delay the switching off of Basic Authentication until 16th August 2010. This is to give developers more time to test in a less 'overloaded' environment.

This gives me a bit more time for development and testing and here is the current status.

I found a plugin called mt-plugin-oauth-framework created by Akira Sawada of 6A Japan that does most of the heavy lifting for authorisation and includes a sample app to tweet from the blog dashboard. This plugin was initially written for MT5.x and requires you to delete some of the libraries in the exlib to work on MT4.x.

The application has been registered on Twitter (as MT-HashTag as the app name HashTag was already taken). This means that any tweets have via MT-HashTag in the meta data (see below)

viaMT-Hashtag.png

I have a alpha version of the plugin working on The Composing Stick the only problem at the moment is that it needs my secret key to work, which should not be distributed for obvious reasons. Twitter is supposed to be fixing this soon (before 16th August soon) so there may be an additional step required to get the plugin working.

On the 30th June Twitter is switching off Basic Authentication on the Twitter API, this means that 3rd party applications that use it, such as the HashTag plugin, will no longer function. I am currently adding support for OAuth to HashTag and will release a new version at the end of the month.

Now on YouTube

Once in while, when answering questions on the Movable Type IRC channel or the support forums I find it easier to show rather than tell, a video can break through a language barrier and miscommunication faster than words. These have been recorded using Jing and uploaded to Screencast.com with a private link to the question asker.

I am now in the process of moving these to The Composing Stick You Tube Channel. Here is the first video to go up.

Creating Per Category Feeds

Introduction

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development

Today we are going to look at a proof of concept that uses jQuery and the Datatables plugin to product a paginated list of entries in Movable Type. By calling it a proof of concept I can get away with a few rough edges and make a series of posts on getting it smooth.

What we are going to do is create a JSON formatted text file with information about the entries for the archive and a archive template that will read the file to create the table. If you want to read ahead you can follow the link to see the final product, a sortable, paginated list of blog entries.

What you need

Step 1: Copy the files to the server

The datatable plugin and the jQuery theme need to be uploaded to the server. In my example the datatable plugin has been uploaded to /jq/dt/ and the theme to /jq/ui/.

Step 2: Creating a JSON formatted text file.

JSON stands for JavaScript Object Notation and is a lightweight data-interchange format, easy for humans to read and write, and easy for machines to parse and generate. You can find more information at http://www.json.org/.

What we need is a template that creates an array called aaData that has and array for each entry with the following information; Date, Title and an excerpt.

Log into the administration page for your blog and from the menu select Design > Templates Design_Templates.png

Under Blog Templates select create index template

Index_Templates.png

Enter JSON Entries as the name of the template at the top of the page.

Enter the following template code:


  {
   "aaData" : [
    <mt:entries lastn="1000">[
      "<mt:entrydate format="%Y-%m-%dT%H:%M:%S">",
      "<a href=\"<mt:entrypermalink>\"><mt:entrytitle></a>",
      "<mt:entryexcerpt words="15">"
      ]<mt:unless name="__last__">,</mt:unless></mt:entries>
   ]
}

Under template options use json_entries.txt as the output file and choose your publishing method. I have chosen via publishing queue so it will be built later via a cron job rather than take up publishing time updating the file.

json_entries.png

So what does this mean?

Well this template will take the last 1000 entries and for each entry output the date and time (as YYYY-MM-DDTHH:MM:SS, although you can change this to any JavaScript supported data format), the title of the post as a link to the post and the first 15 words of the posts as an excerpt. The template will generate a file called json_entries.txt that we will use later.

Step 3: The Archive Page

For this proof of concept we are going to create a blank page with the table in it, in a later post I will go through adding it in to an existing template. So we go through the same process as stage 2 and create a new index template. This time we are going to call it jQuery Archive.

Enter the following code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Archive Test</title>
    <style>
        @import "jq/dt/media/css/demo_page.css";
        @import "jq/dt/media/css/demo_table_jui.css";
        @import "jq/ui/css/smoothness/jquery-ui-1.7.2.custom.css";
    </style>
<script type="text/javascript" language="javascript" src="jq/dt/media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="jq/dt/media/js/jquery.dataTables.js"></script>
		<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
                    oTable= $('#example').dataTable( {
                        "bAutoWidth" : false,
                    "bJQueryUI"  : true,    
                    "bProcessing": true,
                    "bPaginate"  : true,
                    "sPaginationType" : 'full_numbers',
                    "sAjaxSource": 'json_entries.txt',
                    "aoColumns" : [
                        null,
                        {"sType": "html"},
                        null
                        ]
				} );
			} );
        </script>
    </head>
    <body>
        <table cellpadding="0" cellspacing="0" border="0" class="display"
            id="example">
        <thead>
            <tr>
                <th >Date Posted</th>
                <th >Title</th>
                <th>Excerpt</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</body>
</html>

Under template options use jq_archive_demo.html as the output file and choose manual for the publishing method as this only needs to be built once, all the data will be coming from the JSON file we created.

jq_archive_demo.png

So what does this mean?

Let us start from the top.

  • First we import the stylesheets for the datatable plugin and for the jQuery-ui (in our case smoothness).
  • Then we call the jQuery and Datatable script files and initialize the datatable with the id of example; we disable the automatic calculation of column widths as this can slow the process down, we enable the use of themes, enable a processing dialog when sorting, turn on pagination, point it to the file full of data and tell the plugin that the 2nd column contains html so ignore markup when sorting.
  • In the body of the page we create an empty three column table, the plugin needs us to use the thead and tbody tags to make it clear what are headers.

Step 4: Build the Templates Once

To kick start it build the JSON Entries and jQuery Archive templates manually once. The archive should now be working

Troubleshooting

Blank table with no JavaScript errors?

  • Check that json_entries.txt exists on the server. If not try manually building the template again.
  • Check that json_entries.txt has entries in it.
  • Check that the JSON is valid by using JSON Lint

JavaScript errors

  • Check the paths to the script files are correct
  • Check that the table id is correct

Unstyled Table

  • Check the paths to the css files are correct

I have moved the source code for HashTag from my private SVN over to GitHub. If you want to contribute any changes you can find it here http://github.com/TheComposingStick/HashTag.

I have also set up an account on Lighthouse to track bugs and feature requests http://thecomposingstick.lighthouseapp.com/projects/43642/home.

HashTag 2.5 Released

Version 2.5 of my HashTag plugin has now been released. See the Hash Tag Plugin project page for more information.

The major change in 2.5 is the ability to tweet scheduled posts, currently that uses the default settings for the plugin at the time the scheduled post is published.

So what will be happening for Version 3.0? Well there are three things planned:

  1. Support for MT5.x and Open Melody.

  2. Using OAuth to link to your twitter account.

  3. Store tweet options with post / page so that default options are not used for scheduled posts and you can set if the plugin should retweet when you edit a page.

I have now added support for scheduled publishing in my HashTag plugin. It is currently a beta and can be downloaded from this link HashTag Beta 2.5.

Some of the changes:

  • The HashTag options have been moved to a drop down list rather than a radio button to save space.
  • No longer requires XML::Atom
  • Includes option to treat entry tags as HashTags
  • Can tweet scheduled posts. NOTE This will use the plugin default settings (at the time the entry gets published) for tweeting, this can not currently be set on a per post basis.

Last year I wrote a post about getting help with Movable Type. Slightly tongue in cheek, but made a few valid points. Things have moved on now, so here is the updated Tips for getting help with Movable Type.

1. Go to the right place.

  • Purchased a license? Go to http://www.movabletype.com and log in under the account you purchased your license under and click on Open a new ticket.
  • MTOS or a free version? Go to the community forums http://forums.movabletype.com and see if anyone has had a similar problem. If not post a question. You can also run a comprehensive search across Movable Type resources by using mtsearch.
  • Problem with a Plugin? Try contacting the plugin author. If that does not work try the community.

2. Be clear about the issue in your topic title.

Topic titles are your hook, be clear about your problem; Sidebar is being pushed below content is more informative than HELP!!!!!

3. Details.

The more details you can give at the outset the less back and forth later. Try to include

  • The version and distribution e.g. MTOS 4.2, Pro 4.01
  • A link to the site (if relevant).
  • Sample code (if relevant). You will need to encode your code to make sure that it displays correctly. Use a site like http://centricle.com/tools/html-entities/ to do this.
  • Steps to reproduce the problem.

4. Be Polite.

The majority of people that help on the community forums are users, just like you. They help in their spare time. If the problem is particularly complex then you may have to wait for someone to set up a similar configuration to test. It is a sad fact that people are less inclined to help people that spend the majority of their post mad mouthing the product or threatening to move to a rival.

5. Give back to the community

If you found the help useful, pay it forward by helping out another user when you can. OK, maybe this isn't a real tip as such but it is valid. If you have another suggestion for tip 5 let me know by adding a comment.

A problem that comes up every so often on the Movable Type forums is the mixing of recently upgraded system, old Movable Type version 3.x templates and Movable Type version 4 stylesheets. In layman terms "The layout is buggered" or "The syles don't show".

A reason for this is that a number of the divs (html code that allows use to define parts of a page) had their names changed from a functional name such as banner to a semantic name such as header, so your site looks as if it has lost its style. At this point you have three choices:

  1. Start from scratch using new templates and new stylesheets.
  2. Rename all the styles in the stylesheets.
  3. Rename all the divs in your templates.

Each option has it's pros and cons. If you start from scratch you will have to redo any additional customisation you have made. If you rename the styles in the stylesheet upgrades may overwrite them, my preferred option is to rename the divs in the template. the following is a non exhaustive list of name changes

banner -> header
banner-inner -> header-inner
banner-header -> header-name
banner-description -> header-description
pagebody -> content
pagebody-inner -> content-inner

Also the names of the various layouts have been shorten, see my previous post Changing Number of Columns on a Page

Gallery

Recent Comments

  • I am currently testing a major update to the HashTag plugin as Twitter will stop supporting Basic Au...

  • Hi Rob! Thanks for this tutorial! It will come in handy for some of my future projects. Thanks for t...

  • At the moment it relies on Twitter to do the shortening, they apply some voodoo to decide when to sh...

  • This is really useful. Thanks. Wondering if there is any way to shorten the URL in the tweet using b...

  • I have a look at that, at the moment tweet options are not saved with the posts (that is why schedul...

Close