Javascript / jQuery get first class name of element
February 16th, 2012 • javascript, jQuery, snippets • 2 comments
Need to get the first class name of an element? Simple! Imagine having a link with 3 class names
<a id="myelement" href="http://google.com" class="class1 class2 class3">Go to google</a>
$('a#myelement').attr('class').split(' ')[0]
Will result in: class1
IPBWI Fatal error: Class ‘ipsCommand’ not found
December 6th, 2010 • invision power board, ipb, ipbwi, php • No comments
Are you encountering the error “IPBWI Fatal error: Class ‘ipsCommand’ not found” when using IPBWI?
There might be some things you want to check!
- Make sure you are not calling the IPBWI class from a folder that has the word “admin” in the folder path.
- Make sure your board is in online mode
Keeping Original Node Path in a Multilingual Drupal Site
October 30th, 2010 • drupal, hack, i18n, multilanguage, pathauto, php • 2 comments

Let’s say you have to make a multilanguage Drupal website… Besides English it also has to be available in Chinese and Japanese. Drupal makes it really easy for you to set up the basics. Using the Locale and I18n module, most of your site can be translated with a few clicks of your mighty mouse.
The problems come when you are trying to use pathauto in combination with placing the node title ([title-raw]) as path. You will be ending up with Chinese and Japanese characters in your URL. Most modern browsers do support this, but it’s still not a pretty sight and who knows what software/OS does not support it yet.
A solution might be typing Pinyin (for the Chinese version) in your paths… But this can be a long and tedious job (not to mention how many times your client will screw up or forget!).
Pathauto offers a relatively easy solution for our problem. We can “force” Drupal to use the original node paths for the translations too. This will not cause any conflicts as all translations are prepended with their ISO code. Just add the following code to one of your custom modules!
/**
* Because we want to use our original paths, prepended with the language identifier
* We are going to assume the default language is english!
*
* @param $alias
* @param $context
*/
function mymodule_pathauto_alias_alter(&$alias,$context) {
if($context['module'] == 'node' && $context['language'] != 'en') {
$node = node_load($context['entity_id']);
if($node->tnid > 0 && $tnode = node_load($node->tnid)) {
$alias = $tnode->path;
}
}
}
4Gamers.be Launched
October 29th, 2010 • codeigniter, memcache, memcached, mysql, php, portfolio, squid, varnish • No comments
After months of intense labor, togheter with PHP Developer Jens and Designer Michiel, I am pleased to announce that the new website 4gamers.be has reached the stadium of public beta. To make the whole website work, we used PHP, CodeIgniter, MySQL (MyIsam and InnoDB), Varnish and Memcache.
4Gamers is een nieuw belgisch gaming portaal dat nu een groot aantal van de (ex) 9-lives redactie bevat. Op de website vind je reviews, previews, specials, trailers, screenshot en de nieuwste releases. Buiten game nieuws richt 4Gamers zich ook voor een deel op esports en hardware. Zeker een website om eens te bezoeken!
Technical Aspects
CodeIgniter
It was the first time for me to do such a large scale project in CodeIgniter and I have to say CodeIgniter did dissapoint me on several points. The more I used CodeIgniter, the more I noticed that it was lacking basic features (or perhaps I suck at using Google?). First thing I can think of was the session class… I prefer to store my sessions in memcacge, but CI only has two choices (flat file or database). Sure, you could extend the class and rewrite it. But I am not using a framework to do all this AGAIN.
Varnish
Varnish is always a breeze to use. Clear config files and it is slightly faster compared to Squid. The only issue encountered was while using Invision Power Board behind the proxy. It would not properly recognize whether or not a user is logged in (we base our caching on a certain cookie name & value combination). This results in no proxy caching being enabled on the forum… This is quite dissapointing as it can quickly become the backbone of all conversations on 4gamers. Sure enough I’ll find a solution…
Facebook Error Message: Requires valid next URL.
June 16th, 2010 • facebook, php, snippets • 1 comment
Let me start with asking you a few questions!
- Are you having issues with the Facebook API?
- Are you constantly getting the error message “API Error Code: 100 API Error Description: Invalid parameter Error Message: Requires valid next URL.“?
- Are you using the latest official Facebook PHP class?
- Are you redirecting using the PHP header() function?
Well, I might have a solution for you. When calling the function getLoginUrl in the Facebook PHP class, the function will return a HTML encoded string. When outputing this string to your browser, it is rendered/decoded by a browser and this will convert all “safe” charachters to their textual equivalent. This makes that “&” becomes “&” and “%20″ becomes ” “.
However, when using the header() function in PHP, this url will not be rendered/decoded and you are basically sending out a garbled request.
Original
getLoginUrl($params);
header('Location:' . $url);
Solution:
getLoginUrl($params);
$url = str_replace('&','&',urldecode($url));
header('Location:' . $url);


Recent Comments