17th Jan2013

Add customized Google Translate to your website

by Gyro

Google translate has a feature called the Website Translator to help you translate your website.

Here is how it works:

  1. Add your website
  2. Customize the way the Google Translate will look on your website, I usually add a google translate dropdown menu to websites.
  3. Add the custom code to your website.
  4. View your website in another language and click on text that has not been translated to your satisfaction, you will see a popup with the option to submit a translation suggestion. Once a translation suggestion has been submitted, you can review and activate it in the Website Translator

Enjoy :enjoy:


15th Jan2013

Install php-gd on Ubuntu without recompiling php

by Gyro

For some reason one of my client's website stopped showing captcha codes for the mad4joomla component, the server is running nginx with php-fpm instead of Apache.

Looking at the error.log, I got

 [error] 21110#0: *100 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to undefined function imageantialias() in /var/www/clients/client1/web1/web/components/com_mad4joomla/sec/im4.php on line 39"

Time to check the server, that function is supposed to be part of the GD library.

First, I checked if GD was loaded:
# php5 -m | grep -i gd


ok, so GD is there… now on to the function.

# php -r "var_dump( function_exists(‘imageantialias'));"


hmm… :wooty:

So, on I went to google, trying to find out how I can get imageantialias() to work (again)… to my surprise I actually stumbled upon a post talking about the exact same issue, while using the same server setup -- Ubuntu with ISP Config. The solution presented was to recompile php, which I was reluctant to do.

After some more searching I came across this amazing little page (http://nossie.addicts.nl/php5-gd.html) which I am going to post (slightly modified) right here, mainly because it looks like that page could be gone tomorrow…

Getting bundled php-gd working on Ubuntu without having to recompile php

Like many other people out there, I ran into the problem that the version of php-gd shipped with Ubuntu (and Debian) is different from the version used by many other distributions.
The version Ubuntu uses misses some functions like imagerotate and imageantialias, which are needed by an increasing number of software projects.

One solution to this problem is recompiling PHP with the bundled version of GD.
It is not particularly hard to do, but there are a reasons not to do it, one of them being that it is not neccesary.

The following steps solved the problem for me.

Install what is needed to do this:
# sudo apt-get install php5-cli php5-gd rpm mc

Check what version of php you are running (php5 -v). In my case it was 5.3.2-1ubuntu4.7
Go to rpmfind.net and search for php-gd-bundled
Download the version that matches your PHP version and architecture, php-gd-bundled-5.3.2-1mdv2010.1.x86_64.rpm in my case.

If you have installed mc (midnight commander) and rpm, you can use mc to open the downloaded .rpm file (start mc, goto the .rpm file and hit enter)
Inside the .rpm file you will see CONTENT.cpio, navigate to that and hit enter. Goto usr/lib64/php/extensions, there you will find gd-bundled.so.

The original php5-gd is installed at /usr/lib/php5/20090626/gd.so (for my installation), backup the original gd.so, and copy the gd-bundled.so to that location and rename to gd.so (you can copy files with F5 in mc).
The new gd.so expects to find libjpeg.so.8, this was not present on my system, but that can be sovled by creating a symlink from the installed libjpeg.so
On my system I found /usr/lib/libjpeg.so.64.0.0
Create the symlink with:
# ln -s /usr/lib/libjpeg.so.62.0.0 /usr/lib/libjpeg.so.8

This is it, restart apache and you should be running with the bundled version of gd.
# php -r "var_dump(function_exists(‘imageantialias'));"
Should return bool(true) this time.

Now, if there is an update of the php5-gd package, your modified version gets overwritten. To prevent this from happening, you can hold the php5-gd package so it will not be updated.
# aptitude hold php5-gd

I hope this will help you as much as it did me!

Enjoy :enjoy:


14th Jan2013

Search Engine Friendly SEF URLs for Virtuemart 1.1.9

by Gyro

While I still hate joomla, today I stumbled across a neat solution to have virtuemart 1.1.9 use SEF URLs.

All that is required to make it work is turn on SEF URLs in the Global config, disable the suffix, and copy a file into your components/com_virtuemart folder.

You can get all the details here

Enjoy  :enjoy:


10th Jan2013

Why I hate Joomla – Episode 1: URL suffix

by Gyro

Today I had really good fun with Joomla, that is, if you consider cursing and face-palming to be fun.

I have been using CMS systems since 2000 when I first installed php-Nuke. Shortly after that I used xoops to create a website for my clan, xoops is still one of my favorite CMS systems actually, even though WordPress is simply the best IMHO.

I did use Drupal, and actually liked when the developers split and Joomla was born. Now, I have started hating Joomla shortly after it was released. Main reason being their elitism in the forum, it seems that everyone has to comment but no-one actually comes up with genuine solutions. I would never even open their website again, had I no customers with Joomla websites, but since I do, I am on and off forced to deal with this piece of sunshine CMS.

So, now to the 2nd reason of probably 100+ to come:
I have just spend about 4 hours searching for a solution to get Joomla 1.5 to add a trailing slash (/) to the URL, instead of the default .html suffix. I found quite a lot of threads on the Joomla forum discussing how one could add a trailing slash instead of the .html suffix, and once again each thread was gang banged by Joomla Gurus making dumb a…smart comments, and a solution was nowhere to be found, unless you want to use a plugin. I swear, I would have slapped a few of them, were they near me when reading their useless comments… of course I can use a plugin like sh404 that completely hijacks your site and URL structure, but I was looking for the solution, not a work around!

So, after those 4 hours I finally got my Geany out of the bottle and did a few in-file searches, to find the files with the lines that does all the magic.

It is the router.php located in includes/router.php, open it and look for the function &build($url), and change the following within that function:

//Transform the route
$route = str_replace(‘index.php/', ", $route);

To this:
//Transform the route
$route = str_replace(‘index.php/', ", $route).'/';

Next, open libraries/joomla/document/html/renderer/head.php and look for this:

 if(!empty($base)) {
$strHtml .= $tab.'<base href="‘.$document->getBase().'" />'.$lnEnd;

change the above to this:

 if(!empty($base)) {
$strHtml .= $tab.'<base href="http://'.$_SERVER[‘SERVER_NAME'].'/" />'.$lnEnd;

You may have to modify this part a bit (maybe https, or if Joomla is installed in a sub folder, etc.), basically you should have your Homepage URL in the baseurl meta tag in the head section of the source code. :)

That's it! It really is that simple :shock: which makes me even more furious :shout: … I mean appreciative… thinking about all the super smart comments I found in the Joomla forum. I was about to go back to the Joomla forum to post my solution and tell those "Joomla Gurus" how full of sunshine they are, but then I remembered that I got this blog.

Oh, you need to disable showing the URL suffix in the Global Configuration, of course!

Enjoy! :hehehe:

p.s. Operating a blog is a fine form of anger management… :crazy:


15th Dec2012

WordPress 3.5 – PHP Warning: Missing argument 2 for wpdb::prepare()

by Gyro

I just updated a work in progress to WordPress 3.5, and ended up with broken permalinks (to fix that: reset to default permalinks, then set the custom permalinks again), and my favorite plugin "Network Shared Posts" gave a super-long error message on each page, something along the lines of
PHP Warning: Missing argument 2 for wpdb::prepare()…blablabla…

So, after doing some research I found out that the root of all evil are the WordPress developers! Or to be more precise, they decided to make their functions more strict, resulting in a lot of plugins now showing the error "PHP Warning: Missing argument 2 for wpdb::prepare()", after someone updates to WordPress 3.5 and before the author has the chance to update, or in some cases totally rewrite their plugin. Read this article for more on this.

Here is my work-around to literally hide all "PHP Warning: Missing argument 2 for wpdb::prepare()" error messages:



09th Nov2012

Best Image Resize Freeware – Change photo size, dpi, easy!

by Gyro

I seriously can't remember the amount of times I have been asked for the best image resize freeware, to change the photo size or the dpi of an image. Today I finally found the perfect solution for any task, and it's as easy as eating pie. Truly the best image resize freeware, including changing the dpi, and more. And best of all, you can setup each particular resize task you do regularly in the context menu, and the tool will create a new modified version of it.

The best image resize freeware is called Free Batch Photo Resizer, it is only available for Windows, but apart from that… flaw… it is by far best tool I have found in terms of simplicity.

The tool comes in the form of a single executable file called "PhotoResize400.exe",it does not have to be installed, but you can add it to your context menu. For clarity, I will refer to the file as PhotoResize from now on.

[GAN_Image orientation="horizontal" maxads="3" width="300" height="250" ifwidth="900" ifheight="253" target="same" merchid=""]



08th Nov2012

Problems uploading files to ownCloud

by Gyro

I've installed ownCloud a while back and finally got around to test it today.

As ownCloud has a "Music" section, I figured I start by uploading some of my music. I first tried uploading an MP3 file via the web interface, but the spinning wheel would never go away, and an eventual refresh showed no new file. I then tried it with a few small files, and realized that anything over 1MB file size will result in the file not being uploaded, and the original gets deleted by the owncloud sync tool when it was used to upload/sync the file.



07th Nov2012

Top Level Categories vs WP No Category Base for WordPress

by Gyro
Today I had to switch a plugin, so I decided to write a little Top Level Categories vs WP No Category Base for WordPress. The reason for the plugin change is, that Top Level Categories has an issue with sub categories.

I installed Top Level Categories yesterday, just to realize today that I should have taken the name literal TOP LEVEL CATEGORIES, as it throws 404 errors when trying to view the archive of any sub category… so Top Level Categories is really what it says: It makes categories be top level (no /category/ slug in front of the actual category slug) and there can't be any 2nd level categories… since I am using a lot of sub categories, I cannot use Top Level Categories.

562127_Mojo - 125x125



21st Oct2012

Display posts from multiple WordPress Categories – Network Shared Posts

by Gyro
Display posts from multiple WordPress categories with Network Shared Posts.

With Network Shared Posts you can combine posts by categories/tags and display them as if they were one category. You can select the blogs to pull posts from, then define the category slugs and tags to get the posts you want to display. All this is done in one single shortcode featuring an array of settings to further customize the final list of posts. It works perfect to display posts from multiple WordPress categories and tags. You can get the full list of short code arguments on the official website.

This plugin is the perfect companion for any WP Multi Site network, but also works its magic when just running a single block and wanting to combine posts in a way categories and tags simply can't.

With Network Shared Posts plugin you can share posts over WP Multi Site network, you can display the posts from all blogs in your network on any blog, and you can select blogs to display posts from. In short, you can display posts from multiple wordpress categories on one page, including those matching pre-defined tags.




07th Sep2012

Royalty Free Icon Finder

by Gyro

Iconfinder.com provides high quality icons for webdesigners and developers in an easy and efficient way. The site launched in 2007 as the first search engine focused on icons. While not all icons are free, there are loads and loads to choose from and download.




14th Aug2012

WordPress Automatic Update not working

by Gyro
I had an issue with WordPress automatic update not working on my localhost, instead it kept asking me to provide ftp login details?!

Even if I had a FTP server installed, which I don't, I prefer to use the Automatic Update Feature that comes with WordPress.

Of course there can be other similar issues leading to problems with updating wordpress, regardless of being installed locally on you PC, or running on a web server on the Internet. Most likely the reason for these problems will be permission errors, that prevent WordPress from saving any files during the update. So the solution will be to change the permissions for the folders in question.

Should you run a web server on your localhost (apache), then try this in the Terminal:




07th Aug2012

Create search engine optimized multilingual websites

by Gyro

Using WordPress to create search engine optimized multilingual websites is as easy as baking a pie,if you got all the ingredients and are willing to follow the cookbook. This is a guide on how to install WordPress MultiSite with the essential plugins needed to run a search engine optimized website. Follow this guide to create search engine optimized multilingual websites based on WordPress.



06th Aug2012

Multiple WordPress Blogs One Dashboard Setup MultiSite

by Gyro

Today I am setting up a new website that is going to have about 20 different subdomains, each with their own blog about a certain subject. Prior to WordPress 3, you had to use a plugin called WordPress MU (WordPress Multi User or short WPMU), that was then renamed WordPress MultiSite and integrated into WordPress.



30th Jul2012

Setup Virtual Hosts using Apache2 on Ubuntu 12.04

by Gyro

When I started programming website on a localhost, I often ran into issues setting up SEF URLs. So, I started using virtual hosts by creating fake domain names and then make them connect to the local apache server via the hosts file.

For example, if I work on webdesignblog.asia on my localhost, I am accessing webdesignblog.dev, which is a fake domain linked to my localhost via the virtual hosts (enabled sites) and hosts modifications.



21st Jul2012

CSS3 Background Gradient Generator

by Gyro

I was just looking for the right way to create gradient backgrounds using css3 that work in all modern browers.

Instead of the typical guide with loads of text to scan, I stumbled upon this very useful generator.



17th Jul2012

Firefox does not support getElementsByClassName

by Gyro

This is just a friendly reminder that Firefox does not support getElementsByClassName…

but not to worry, unless you are doing some really weird programming, we can use getElements to accomplish almost the same thing.



20th Jun2012

Chimply generate loading image indicators, buttons and badges for your website

by Gyro

Chimply is a website to easily generate loading image indicators, buttons and badges.

Chimply can be used to manipulate images by resizing and cropping them.

Create professional images with Chimply. It's easy and free!



12th Jun2012

Display Links Categories on WordPress using ShortCodes

by Gyro

While looking for the best way to do what the title says, I stumbled upon this great little function. All you need to do is add it to the current ThemeFunctions.php and then you can display any category anywhere in WordPress.