OK Sushi

Force links open in a new window with jQuery

Occasionally, you will get a client that requires that all external links on their site open in a new window. In the past I have argued against this, on the grounds that a user should be able to decide for themselves where the link opens, but now I don’t really worry about it.

Using jQuery, forcing external links to open in a new window is easy.

What we do is parse the document for any links pointing outside, and add a click handler to them that makes the new window. Easy? Easy.

$(document).ready(function() { $("a[@href^=http]").click(function(){ //find the links pointing to a URL if(this.href.indexOf(location.hostname) == -1) { //check if they point outside window.open( $(this).attr('href') ); //force open the new window return false; } }); });

Comment

What I have learned about Magento

Magento eCommerce Promises to be an excellent open source solution to a common problem – how best to sell goods on the Internet. On paper, it kicks some serious ass (or arse, depending on your location), The sales reporting is fantastic. Adding new products is relatively easy. It comes stock with support for a whole bunch of different payment gateways. Great!

As I wrap up a large Magento project, there have been some large mistakes that cost us weeks of development. I want to document them here for posterity, and hopefully Google will pick them up for anyone trying to decide if Magento is right for them and their project.

Note

Let it be known that I am a tinkerer, and probably got myself into a lot of trouble for not RTFMing in the first place. I tried to squeeze Magento into a design box that it was not supposed to fit into. It works not, though, so meh.

Javascript

Magento REQUIRES Javascript in order to function. There is no graceful degradation here – if it’s not on, it does NOT work. No arguments, no coaxing, no nothing. So what did I do? I deleted all the javascript calls and tried to get it to work.

Cost: 1 week

Inline Language

Want to change the text of something in the cart? You need to change it in the source files. Language is not abstracted for a quick presto change, as it is in Zencart or other carts. This sucks!

Cost: a frequent annoyance

Templating System

How do you spell XML? I’m still not sure. I thought Smarty was annoying, but it is nothing on the xml hybrid system that Magento employs. You don’t want a three column layout? Are you sure? Really? Well, too bad. It’s there – live with it.

Cost: A lot. If you want to redesign a Magento site, just change the colours. Don’t attempt anything fancy, please.

Crazy shipping configurations

If you are shipping products, and you are not in the States, prepare for a laugh. It’s fun, especially setting up shipping tables. In Australia, we use 4 digit Post Codes. so, I needed to upload a CSV with 9999 lines, each with the cost of shipping to that post code. There must be an easier way!

Cost: Probably not too long, but it was annoying as hell.

Support

Huh? What’s support? There aint none. Traverse the forums for a whole bunch of unanswered threads.

Cost: Depends. Hard to tell.

So, I may add more as time permits. If you are going stock, then I would probably recommend Magento. Clients love the backend interface. If you are a developer though, heed this advice:

Only modify those files that you have to – keep your custom template directory as empty as possible

That is all.

Comment

Detroit TV - The New Dance Show

I don’t really watch much tv these days, but I’d watch this show religiously.

I love artifacts of popular culture like this:

Comment

French Onion Soup

This is for me as much as anyone else – I wrote this recipe down in a log book, and every time I go to find it I lose half an hour of my life.

French Onion Soup – The recipe

You need:

  • 60g butter
  • 2tbsp olive oil
  • 6 brown onions
  • 2 tsp brown sugar
  • 2 tbsp plain flour
  • 4 cups of a good beef stock
  1. Melt the butter on a fairly low heat
  2. Add the thinly sliced onions and some salt, cook for 45-50 minutes, stirring every few minutes
  3. Add in the brown sugar, cook for 10 mins
  4. Add in the flour, cook for 2 mins
  5. Add in the stock with 2 cups of water, bring to a simmer and cook for 15 minutes

I usually make nice cheesy toast things with sliced baguette. Rub both sides of a slice with garlic, sprinkle the top with grated cheese and cook in the oven for five minutes.

Place the cheese toast in the bowl and pour the soup over the top.

Crazy delcious!

Comment

Embedding your Twitter timeline on your desktop

Since I moved full-time to my new (shiny, beautiful) MacBook Pro, I have been tinkering with various solutions to my Twitter problem. I want to be able to update whenever I want, but I don’t want visual alerts that people I am following have posted. I would, however, like to have my timeline somewhere easy-to-see, so I don’t forget about it. Sound confusing? Perhaps.

So I came up with a quick and dirty solution to embed my Twitter timeline to my desktop.

  1. Download and install the Twitter gem for Ruby – a great little tool that allows you to use Twitter via the command line
  2. Download and install the GeekTool – a neat little app that allows you to embed the results of a shell action, files or pictures on your desktop
  3. Create a new console in GeekTool (of type Shell) with the following command:
    /usr/local/bin/twitter timeline
  4. Style accordingly

Enjoy

Comment

Older

My flickr photos