Finding the Perfect Lightbox

Posted: May 19th, 2009 | Author: | Filed under: JS | Tags: , | 3 Comments »

I need a proper lightbox. Now there are plenty of lightboxes out there that should satisfy my needs, but I could not find the perfect fit. My ‘demands’ are as follows:

  • Flawless (X)HTML, also the generated code
  • Can be used to display images, partial HTML, hidden content from same page, iframes (for form processing) and request contents with AJAX.
  • auto adjust size to contents, unless overruled by settings.
  • Easily styled through external CSS (I do not want to apply styles using JS)
  • Can group images into sets and navigate through them
  • Stacking of boxes (open lightbox from within a lightbox)
  • jQuery may be used, but no other library (as it is already available in this specific project)

Read the rest of this entry »


The use of CSS Hacks

Posted: March 21st, 2009 | Author: | Filed under: CSS | Tags: , , , | Comments Off on The use of CSS Hacks

As you all know there are a couple of differences in rendering your website in different browsers (Internet Explorer 6/ 7 / 8, FireFox 2 / 3, Opera and Safari).

You as front-end developer have the responsibility to make sure your webpages are supported for all browsers. Microsoft introduced “conditional commenting” as a sollution, but often you do not want to add in a whole CSS file to fix a single pixel. In these cases you need a “hack” in CSS to accomplish this.

Before I give the solution to your rendering differences in Internet Explorer, you need to understand these hacks should only be used when all other options are eliminated since they are mentioned as final solutions for tiny bugs.

Read the rest of this entry »


iFrames, IE and session cookies

Posted: November 6th, 2008 | Author: | Filed under: PHP | Tags: , , , | Comments Off on iFrames, IE and session cookies

Session is lost when browsing in an iFrame

A very large problem with a very small solution: For security reasons Internet Explorer prevents carrying over session variables from one page to another when browsing in an iFrame. To enable this we somehow need to tell IE that the page we’re looking at is trusted and safe. This can be done by adding either a meta tag or a header (in this example sent using PHP) to the framed page:

<meta http-equiv="P3P" content='CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'>
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

Solution source: Sitepoint.com


Enums in PHP5

Posted: September 22nd, 2008 | Author: | Filed under: PHP | Comments Off on Enums in PHP5

Enums are very usefull. Unfortunately php does not natively implement it as a type. Not to worry, there is an easy workaround. To implement a simple status enum having values for “ok”, “not-ok” and “uncertain”, try:

abstract class Status implements Enum {
	const UNCERTAIN = 0; // or any other value you wish
	const OK = 1;
	const NOT_OK = 2;

	public static function values(){
		return new ArrayIterator(array(Status::UNCERTAIN,
			 Status::OK,
			 Status::NOT_OK));
	}
}

The values of the enumeration are now immutable, which makes it preferable to implementing such a construct as an array. The enum interface provides the static values() function that allows the caller to iterate over the values that have been enumerated.

interface Enum {
	/**
	 * Return an array containing the enum values to iterate over
	 * @return Traversable Contains enum values
	 */
	public static function values();
}

And that’s it. To use it, call Status::OK and the right value is used throughout your application. To loop, simply call foreach (Status::values() as $enum_value){...}.

This approach works well when several classes use the same naming for (some of) their properties. When using enums in a database, using this pattern will ensure the correct values are used. Also this will allow easy modification of the values in your app when the values in the database need to be changed.


Benchmarking DOMDocument creation with PHP

Posted: September 19th, 2008 | Author: | Filed under: PHP | Tags: | 2 Comments »

Representing data as XML has several advantages, all of which are not in the scope of this post. We will test several ways of creating a DOMDocument instance with a simple XML document. We will not be discussing differences between DOMDocument or SimpleXML or any of the other ways available to build XML structures. This post is concerned with the building (no manipulation either) of a simple XML tree.

Read the rest of this entry »


Benchmarking call_user_func

Posted: September 19th, 2008 | Author: | Filed under: PHP | Tags: | Comments Off on Benchmarking call_user_func

Calling object methods can be done in several ways:

  1. $oObject->method($param);
  2. $sMethod = 'method'; $oObject->{$sMethod}($param);
  3. call_user_func(array($oObject, 'method'), $param);

(call_user_method() function has been deprecated as of PHP 4.1.0, c.f. php.net.)

Intuitively the first type method calling is the preferred way to go both in terms of perfromance and readability. However, for the sake of generality (freedom, scripting or just exploiting the possibilities php provides), one of the latter two could be preferred. A quick performance comparisson may show which to use.

Read the rest of this entry »


Choose your domain extention with care

Posted: March 26th, 2008 | Author: | Filed under: SEO | Tags: , , , , | Comments Off on Choose your domain extention with care

Who is your target group? Where do they live? The choice of the right domain extension (TLD) is crucial. We found a case where the effects of this choice are transparent.

Druppels (meaning “drops” in Dutch)

For The Netherlands and Belgium the common language is Dutch. So Belgian websites show up among the search results on google.nl and vise versa. Both druppels.nl and druppels.be have no real information regarding “drops”, they are both chosen as a name for the website (call it a brand). Searching for “druppels” on Google.be gives us (as expected) druppels.be as first result. Since druppels.be has a PageRank of 6 and druppels.nl has a PageRank of 3, it would be expected that druppels.be also shows up first on Google.nl, since the language is the same and the PageRank of druppels.be far exceeds that of druppels.nl. The result are the opposite, druppels.nl comes up first, the only difference being the domain extension, despite the lower PageRank. This means that my location (determined by .nl in google.nl) influences which sites show up, even though Google isn’t aware of the exact location behind druppels.nl (but expects it to be The Netherlands due to the extension).

Make your choice

So where do you want your business to be? Do you focus on regional visitors, don’t use a .com or .eu domain, if you don’t focus at all .com will do fine. Don’t like the dollar exchange rates? .eu is your choice.

This doesn’t mean you don’t have to register alternatives, but make sure the primary domain is targeted at your audience. This is an example however, where pretending to be large and international (by using a .com domain name) might just go at the cost of search engine traffic. Make sure your domain name and extension match your content!

Update (8-8-’08):

Google posted an article on multilingual websites in which they say:

Let’s say your German content is specifically for users from Germany and not as relevant for German-speaking users in Austria or Switzerland. In this case, you’d want to register a domain on the .de TLD. German users will identify your site as a local one they are more likely to trust.

Trust is important to Google, they will most likely send their visitors to a website they asume the visitor will trust most.