oliver's blog

Drupal 8 PSR-4 Form compatibility in Drupal 7

This post is sponsored by Capgemini.

Up until Drupal 8 there has been little to encourage well organised code. It now has PSR-4 autoloading so your classes are automatically included. Even though Drupal 8 is just round the corner, a lot of us will still be using Drupal 7 for quite a while, however that doesn’t mean we can’t benefit from this structure in Drupal 7.

This post covers two parts:

  1. Autoloading class files.

Improving SEO by setting an image's filename as its alt or title field

Images are often neglected in SEO and they provide a great opportunity to rank well in universal search (search results such as images, video and places).

For images to rank well you need three a minimum of three things set up to target your keyword phrase:

Additionally you should add:

Best tool to compress a transparent png file to its smallest

I've played around with the usual optipng, pngcrush, advpng but by far the best results are found with pngquant which is actually a lossy compressor.

Depending on the settings the "loss" can be invisible so you get the benefits of a small file with none of the drawbacks.

pngquant --quality=65-80

Yakuake terminal not saving bash history

I love KDE and Kubuntu. I also love Yakuake for quick access to a terminal however one thing that's always bugged me is the fact that it doesn't store your command history when you exit.

I've just found the ideal solution:
In your .bashrc file (create it in your home directory if it doesn't exist already) add:

shopt -s histappend
PROMPT_COMMAND='history -a'

Website Forms not saving in Wordpress, Drupal or PHP

On very large forms (with lots of form elements) you can find that your form does not save. This is due to a PHP setting max_input_vars. The default setting for this is usually 1000. That means that if the form has more than 1000 elements then elements past 1000 will be omitted. Therefore the form can save partially.

This can be particularly prevalent in permissions forms that have multiple roles and multiple permissions e.g. 100 permissions and ten roles will take you to the limit quite easily.

Online Business Optimisation: Get the most out of your online business.

The full version of my book is now available on Amazon. If you would like to really get your website and online presence working for you then this book is for you: Get your copy now!

An exercise in SEO

I'm currently creating a course on how to maximise your profits from your online business.

As part of this course I am working with a domain I have registered www.websitefromscratch.net

As the domain suggests, this course will take you all the way from building your website from scratch, through to building multiple streams of traffic, generating leads and converting these leads into paying clients.

However it doesn't stop there. You also need to insure your clients are happy, in order to upsell and cross sell or sell other similar products to them.

Getting the active database in Drupal

Sometimes when you're debugging you might want to check which is the currently selected database. The following code will print out the current database to the messages area:

(db_result(db_query('select database()')));

Resizing and moving maximized windows in Kubuntu Oneiric

I use the Meta (Alt by default) button together with the mouse to move and resize windows. You can hold Alt, click on the window and move it, if it's not maximised, you can also resize with middle click. I believe Ubuntu has this as well but you can't resize.

If a window is maximised then you can't move it but there used to be a setting 'Allow resizing of maximised windows'. In Oneiric this appears to have disappeared however the setting is actually still there. It's just called:

Window Behaviour > Moving > Display borders on maximized windows

How to inspect the CSS hover and active style

In Firebug it's possible to get the :hover and :active pseudo class style by selecting ':hover' or ':active' from the 'Style' dropdown in the inspector:

Firebug inspect CSS hoverFirebug inspect CSS hover

User login

Author of...

  • Did you know today is world peace day? http://t.co/5woHsuaQ 8 years 18 weeks ago
  • If you would like to donate to Sport relief and change people's lives the address is: http://t.co/riQCnQEq 8 years 44 weeks ago
  • Why big businesses cannot compete with small businesses: http://t.co/dNaQVJv3 8 years 47 weeks ago
  • The newest addition to my kindle: 'Know Me, Like Me, Follow Me' - Social networking for business by @pennypower http://t.co/hPVMRQKe 8 years 47 weeks ago
  • Using YouTube videos to improve your exposure and credibility http://t.co/rLKx6ByY 8 years 48 weeks ago
  • Penny power making great points about social media being personal #kpiday 8 years 48 weeks ago
  • @philhawksworth Yes, I lust after kate 8 years 49 weeks ago
  • Monday the 13th is the new Friday 13th. 8 years 50 weeks ago
Oliver Polden