Martin Downton

PHP Web Developer working at "Fluid Creativity", a creative design company based in Manchester, UK

http://martindownton.eu for more info


Recent tracks

  • Oregon by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    31 hours ago
  • Everyday by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    31 hours ago
  • All Things to All Men (feat. Roots Manuva) by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    31 hours ago
  • Man With the Movie Camera by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    31 hours ago
  • Evolution (feat. Fontella Bass) by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    31 hours ago
  • Flite by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    31 hours ago
  • Burn Out by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    32 hours ago
  • All That You Give (feat. Fontella Bass) by {u'mbid': u'7c158ea8-c0aa-410e-bdc1-20bba9759577', u'#text': u'The Cinematic Orchestra'}
    32 hours ago
  • The Last Remaining Light by {u'mbid': u'020bfbb4-05c3-4c86-b372-17825c262094', u'#text': u'Audioslave'}
    2 days ago
  • Ára bátur by {u'mbid': u'f6f2326f-6b25-4170-b89d-e235b25508e8', u'#text': u'Sigur R\xf3s'}
    3 days ago

Top tracks

Posts

January 14, 07:16 PM

I was researching the Twitter search API the other day when I came across quite a nice web standard that I wasn’t aware of before.

I had been searching for “twitter search xml” to try and access the search feeds that twitter provides (post on how to make a spam bot coming soon!) when I saw a link to http://search.twitter.com/opensearch.xml, which it turned out wasn’t what I was after.

After a little digging it turns out that providing an opensearch.xml file on your site is a way of telling modern browsers that there is a search functionality. The user can then add it to their browsers quick search bar, along with Google, Bing, Amazon, Wikipedia etc. so that they can search your site at a later date.

“So how do I put this on my site?” I hear you cry… There are two steps you will need to follow to get this to work.

1. Define your XML file

This is Twitter’s XML file:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
	<ShortName>Twitter Search</ShortName>
	<Description>Realtime Twitter Search</Description>
	<Url type="text/html" method="get" template="http://search.twitter.com/search?q={searchTerms}"/>
	<Image width="16" height="16">http://search.twitter.com/favicon.png</Image>
	<InputEncoding>UTF-8</InputEncoding>
	<SearchForm>http://search.twitter.com/</SearchForm>
</OpenSearchDescription>

Obviously you will need to replace these details with your own. One key point is that you must be using GET data to pass your search term from your search form to your results page. This means that your search term will be in the address bar after you have submitted it. This needs to then be replaced with {searchTerms} as in the example above.

2. Add a meta-tag to the <head> of your document

Add the following meta tag to the head of your page, again replacing the details with your own.

<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Twitter Search">

And that’s it! So now when someone goes onto your site their current search icon should go blue and when clicked it will give the user a link to add the custom search.

Best Uses

As you can imagine this might not be something that many users are going to install, especially on a simple website like a blog or portfolio, but it would be a great addition to an e-commerce store and might be the difference between a user coming back and purchasing a product from you rather than someone else.

#postaweek2011 2/52


January 06, 01:30 PM

The first thing I do when I log in to the Admin on a fresh install of Magento is delete all of the message notifications, or at least mark them as read to remove the banner from every page. Imagine my annoyance when I installed a fresh copy of version 1.4.2.0 to find this:

So basically there’s no way to mark the messages as read.

There is an issue for this in the bug tracker as well as a basic solution; the solution isn’t obvious for a beginner so here’s a step by step guide on how to fix it, as well as a reminder on how to edit core files without actually editing core files:

  1. The code that is causing the error is located in the “Template.php” file which is located in “app/code/core/Mage/Core/Block/Template.php”.
  2. If we were to edit the file directly then it would be overwritten when we next upgrade Magento. Whilst in this instance it is probably OK for this to happen, it’s not good practice so what we do is replicate the file in our local code base and then make the changes. The easiest way to do this is to mimic the file structure above but change the highlighted “core” to “local”, giving us ”app/code/local/Mage/Core/Block/Template.php”.
  3. Open the file and add this block of code to the end:
    public function getRowUrl($row){
    	return $this-&gt;getUrl('*/*/edit', array('instance_id' =&gt; $row-&gt;getId()));
    }

    …making sure that you put this before the curly bracket that closes the class.

  4. Delete all of the annoying messages… and relax.

There is another method detailed on the bug tracker page in post 3 but the same principles apply regarding the file structure you should use.

#postaweek2011 1/52


January 01, 10:38 AM

What? Commit to posting once a week, every week for a whole year? Hey that’s not a bad idea. The problem for me is going to be sticking to it – I’m terrible at sticking to things – but that is the whole point I suppose.

Just in case you haven’t heard about this WordPress are encouraging us all to fill up their servers!

I figure I’m not going to be able to post something big every week so it’ll most likely be something smaller, probably just how to solve a problem or achieve a piece of functionality in WordPress or Magento.

And finally… It will hopefully encourage me to finally get around to finishing off my portfolio website and blog.

So, Happy new year and here’s to some more frequent blogging…


November 05, 10:42 AM

Fact: AutoHotKey is Awesome

If you haven’t heard of it then I would encourage you to check it out as it makes doing anything in windows a whole lot more tolerable. The program basically automates keypresses in windows, but can access all sorts of actions within windows, such as resizing windows and accessing your clipboard. There is a great article on AutoHotKey on Lifehacker.com.

There is a bit of a learning curve but the documentation on the site is very good and the official forum serves as a good fallback if you are struggling to do something.

What I wanted to do in this post is show you how easy simple scripts can be. This is a script that enables your mouse to perform an AltTab using the right click and mousewheel:

Rbutton & WheelDown::AltTab
Rbutton & WheelUp::ShiftAltTab
RButton::SendInput {RButton}

To Break this down:

;This line triggers an "AltTab" when the right mouse button is held down and the mousewheel is scrolled down and the next triggers "ShiftAltTab" when the wheel is scrolled up
Rbutton &amp; WheelDown::AltTab
Rbutton &amp; WheelUp::ShiftAltTab
;This line re-assigns the right mouse button to trigger a right click as it is overwritten above
RButton::SendInput {RButton}

Simple.

You can also trigger a Ctrl + Tab to switch between tabs in your browser using the following:

RButton &amp; MButton::SendInput ^{tab}
RButton &amp; LButton::SendInput ^+{tab}

You will need to make these the 3rd and 4th lines to make sure the right click is remapped.

Running your AutoHotKey Script

Once you have finished a script it can be run in several ways. The most simple is to install AutoHotKey, rename your script with an .ahk extension and double click. This will put a green icon with a white H in your Notification Area which can be suspended or exited when you want to stop your script.

You can also compile your script into an .exe but have a look on the AutoHotKey website to see how to do this.

Enjoy!


January 17, 01:31 PM

My brandspankingnew (Yes, that is a word) website is nearly finished. http://martindownton.eu.


abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz