While building a wordpress theme that has multilingual support, I needed to know what the current language was for fixing some static parts of my template.
After searching a bit on the WPML site, I found a code example where you are shown howto create your own language selector menu:
http://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/
I then wrote this function to get [...]
WPML, what is the current language?
31 May 2010 2 Comments
Using link_to in rails with :confirm and :method
27 May 2010 No Comments
Every time i’m going to use the link_to method in rails, I always seem to get a lot of errors.
The documentation states:
link_to(name, options = {}, html_options = nil)
link_to(options = {}, html_options = nil) do
# name
end
URL to the rails docs: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001597
And gives a list of options you can [...]
Fixing symlinks in Mac OS 10 + built in Apache
3 May 2010 3 Comments
The other night I was fiddling about with my macbook, trying to setup a “MySQL-Apache-PHP” server on my system. Digging a bit about the system and googling a bit, it seems that the system comes with a built in apache server and php installation.
I thought to myself, why not use the built in server instead of installing a MAMP package?
Anyways, seconds went by and I found the option in the system preferences, turned on “web sharing” and excitedly headed on to localhost. It worked perfectly, now I just needed to set it up as it was on my linux desktop.
The apache’s httpd.conf file is located in the folder: /private/etc/apache2/httpd.conf
(I used textmate to edit the file.)
What I wanted to do was, since I’m the only user on this laptop, I wanted my Sites folder to have a www “folder”, which was a symlink to a folder in my Documents folder. The symlink would then point to the webapp I was currently coding.
(php) php-mvc-base project released
12 Apr 2010 1 Comment
Whenever I create a new PHP project I use a certain base structure.
This structure allows me to have pretty URLs and have a nice way of configuring the database connections. Furthermore this structure also allows me to use a form of plugins in my system.
Hooking up Ctrl+S using JS+Prototypejs
26 Feb 2010 Comments Off
Did you ever find yourself in a position where having Ctrl+S hooked up as an event would be great? Well I have and doing a fast search on google gave me this page OpenJs.com – Keyboard shortcuts.
While this page is great, I needed to have a script that was written in prototypejs, since this is what we use at work (It’s a left over from the early Rails days, where prototypejs was tha bomb).
(php) flash-message plugin
9 Feb 2010 Comments Off
For a long time I’ve wanted a way to send messages from my controller to my view, when posting data. The message could be “Your update went well” or some error.
Use Rails’ form_tag with care
27 Jan 2010 Comments Off
Today at work I was fiddling with some forms in an admin interface. When I had to make an update form, the data didn’t hit the correct controller action.
If you ever get the message ActionController::MethodNotAllowed, then you’ve created your form wrong!
(php) Paginate component
17 Jan 2010 Comments Off
After removing CakePHP from my site, I really missed having pagination on it. So I created a small PHP component I’ve called Paginate and I’ve released it over on github: http://github.com/jimmiw/php-paginate.
It’s designed to be easy to use (only 3 lines of code!), and the output should be easy to style.
I hope you enjoy it
You gotta design!
11 Jan 2010 Comments Off
After seeing a tweet from @smashingmag about designing a small piece of graphics everyday, I and @janusclemmensen decided to try it out.
Here is my contribution for day11:

Ajax Upload component
16 Sep 2009 Comments Off
Today I created a “ajax upload” component, that mimics the behaviour google has in their gmail application, when you attach files to an email.
It’s not totally complete yet and no exambles have been added yet. They will come later though!
Head over to github.com/jimmiw and check it out