Toby's Development Blog Just another PHP / Javascript Developer

27Nov/090

Adding jQuery to Wordpress

Adding jQuery to WordpressFor my last post (talking about a really cool jQuery plugin) I really wanted to display the talked about effect on the site, not least because I wanted to play about with it some!

In order to do that I had to make some changes to my theme, which I figured I should document.

I went into my theme directory and created /js/themename.js

I edited the header (themename/header.php) to include jQuery and /js/themename.js...

<script src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-1.3.2.min.js" type="text/javascript" ></script>
<script src="<?php bloginfo('stylesheet_directory'); ?>/js/lightword.js" type="text/javascript" ></script>

Inside of themename.js I created my $(document).ready() call and gave it the code it required.

I uploaded /themename/header.php, /themename/js/themename.js and themename/js/jquery-1.3.2.min.js to the site.

That is it!

  • Digg
  • Delicious
  • Facebook
  • Reddit
  • Ping
  • Twitter
  • Share/Save/Bookmark
27Nov/093

InFrame – Dynamic iFrame creation with jQuery

jQuery spends a lot of time impressing the shit out of me, one example of it doing it recently is with Vile Work's inFrame (one person has reported an issue with this site and viruses, I cannot replicate though.).

What this plugin does is capture any links containing a certain class and instead of having them display in the current window it will create an iFrame on the fly for the content to display into.

We all know that iFrames are bad because they hide stuff from crawlers and different accessibility tools, however one of the really smart things about this is that because it looks for links of a certain class anyone coming along without JavaScript installed (say, a search engine for example) will just follow the link as normal with no negative effect.

I can see loads of potential uses for this tool and look forward to playing with it in an actual project.

Here is it in action.

Is twitter up?

Cool, huh?

  • Digg
  • Delicious
  • Facebook
  • Reddit
  • Ping
  • Twitter
  • Share/Save/Bookmark
24Nov/092

Online resources for web development

Here are a selection of online resources that I use when developing.  Some I use far too often, and some I have to say I use far too little!

This list is by no means comprehensive, and I will be updating it over time.

I am always on the look out for new sites like these, so please feel free to comment this post with your suggestions.

codingforums.com
I am a bit of a sucker for forums and have found this one to have a good bunch of people behind it, they are willing to help and very welcoming.

php.net
Self explanatory really, the docs on this site tell you how each and every PHP method should be used with some excellent community based examples.

stackoverflow.com
Think of a free version of Experts Exchange aimed directly at programmers and about 10 times better, that is what Stack Overflow is.  Sign up for a free account and ask questions (from the very very simple, to the very very complex, all levels are catered for).

tizag.com
A very basic tutorial website covering a range of languages, for when you have a bit of a brain freeze and know the solution is way too simple to ask for help!

validator.w3.org
Valid HTML is happy HTML (you can also validate your CSS there too).

w3schools.com
Much like Tizag only much more established.

  • Digg
  • Delicious
  • Facebook
  • Reddit
  • Ping
  • Twitter
  • Share/Save/Bookmark
19Nov/091

Exploring Built In Functions

ScreenshotAn issue I have been pondering lately is how much time to dedicate to trawling through programming language manuals and doc files looking for built in functions to perform a particular task.

Obviously there are some functions that you can pretty much take for granted will be provided for by the language, an example would be returning the size of the array.  We know that each language might have slightly different terminology for performing this basic task but we also know it should be there and is most likely going to be easy to find - a very quick google will tell you what you need to know and you can carry on with your life.

But what about some of the more fiddly functions?  An example would be the large array*1 of functions you can call in PHP to do some fairly cool stuff to arrays and I know that the majority of these functions are not going to be available in say JavaScript.  Normally I would have a quick google and if nothing immediately jumps out at me and I know I have a rough idea of how to recreate this bit of code then I will just go ahead and write it myself.  I think there are a few pros and cons to what I do.

Pros;

  • I get to think about the best way to make these functions.
  • I get to create the function exactly how I want.
  • I get to create!
  • I am not wasting time searching for something that may not exist.

Cons;

  • It is generally going to be slower to write it from scratch than it would be to spend some more time digging about to find the appropriate function.
  • I am not fully getting my teeth into the language or taking benefit from its internal libraries.
  • If there is an in built method already in place, I am sure it is going to be far more optimised for the task than my method is*2

Lets now say that we have looked through the manual for the language and done some googling and we are pretty confident that a function doesn't exist natively, it seems to me that we then have a couple of choices; we can see if someone else has created similar methods/libraries/functions or we can create them ourselves.  Obviously there are pros and cons to finding someone else's.

Pros;

  • Can be quicker.
  • Already documented.
  • Sometimes there is community support

Cons;

  • It will never do 100% what you want it to do.
  • You will never learn how to solve the problem for yourself (but if there is a solution, then is it worth you solving it again?)

The pros and cons for creating it yourself is pretty much the reverse of the above!

I guess what I am asking, in a rather round about way, is how much time do you spending searching for a pre-built solution against writing your own?

*1 - Do you see what I did there? An array of functions? Har har har!!
*2 - Actually, I am not convinced this is true, most in built functions have to be fairly generic, I can streamline my functions to do what I want them to do, but for example I know that creating a function to return the size of an array is going to be less efficient at run time than using sizeof(), no matter what awesome stuff I do within that method.

  • Digg
  • Delicious
  • Facebook
  • Reddit
  • Ping
  • Twitter
  • Share/Save/Bookmark
14Nov/090

Bloody Windows…

About a month or two ago I was given a Mac in work to use to replace my shitty old Windows laptop.

I have to admit I was very dubious at the start because I have a deep hatred for the Mac fanboy culture (and I still do) however I was quickly won round by the Mac's responsive hardware and slick OS.

It didn't take long to realise why some people where very fanboyish about the whole thing (there is still no excuse for it though!) and I starting considering changing my home setup to a Mac.

The main reason why I didn't was because my Windows machine is relatively new and fairly bitching, it cost a lot and I would like to get a lot of use out of it.

That and the fact that Windows is a fine operating system for what I use it for, sure there are annoyances but there is nothing I personally need to do that Windows Vista couldn't do for me.

My stance changed about 4 hours ago however whenever after installing the latest service pack  the night before (how ruddy cavalier of me!) my computer refused to start. Long story short the service pack seemed to have half installed and borked the OS completely, I ran different repairs on it but to no avail.

Now I am in the process of downloading a live Linux CD in order to run and then backup a couple of files/folders that I would like but are deemed not important enough to have running on my normal backups. Once this is done I will be installing Windows 7 onto the machine and starting from scratch.

I have played about with Windows 7 and like it, but the very first time it gives me any amount of crap I think the back will be broken and an order will be being placed with Apple.

Bloody Windows...

(p.s that image was found by googling the term shit vista!)

  • Digg
  • Delicious
  • Facebook
  • Reddit
  • Ping
  • Twitter
  • Share/Save/Bookmark

Hello

I am a PHP and JavaScript developer who works for Team Solutionz.

This website is what I use to talk about things most of my friends don't want me to talk about to them! For some reason they find coding alien and boring... I have strange friends.

Subscribe via RSS

New Posts

Old Posts

Categories

Links

Other Links

Sign Up and Comment!

What I talk about