traffic-toggle-control

Google Maps API V3 – Traffic toggle button

15

With the Google Maps API V3 it’s very easy to make the built-in traffic overlay visible.

This is possible with the following code:

var options = {     zoom: myDefaultZoom,     center: new google.maps.LatLng(myLatitude, myLongitude),     mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById('map-container'), options); var trafficLayer = new google.maps.TrafficLayer(); trafficLayer.setMap(map);

Too bad that there is no simple line of code to enable a built-in traffic toggle control (Buttons on the map are called controls). So I created the piece of code More >

Doctrine 2 – Use foreign key as field in DQL

2

In doctrine 2 there are by default no foreign key fields a ID. For example your “product” entity might have a “shop” property, but no “shopId” property.

To get all the products that belong to a shop you would always have to make a join like this:

/* @var $em \Doctrine\ORM\EntityManager */ $result = $em->createQuery("SELECT p FROM My\Entity\Product p     JOIN p.shop s WHERE s.id = :shopId" )->setParameter('shopId', 1)  ->getOneOrNullResult();

But in certain situations it would be nice to use the foreign key column directly, in this case “shopId”. That More >

Drupal 7 – Show one teaser image of multiple added images

0

Since Drupal 7 the CCK module is for a large part integrated into the Drupal core. You can very easily create and add new fields to a certain node type. One of the available field types is “field_image”. You can set the setting that multiple images are allowed.

If you create a view that displays all the node teasers, the images will be visible there. That all images are appended is nice, but actually only for the full node and not the teaser. So if you only want one image to show in the teaser you have to override the More >

Drupal 7 – Multi language front page

4

It’s not possible in Drupal 7 to define a front page per language with the core or i18n module or something. However with a little bit of code it’s still not so hard to do.

Create a custom module “alter” for example. Create the folder in “sites/all/modules/alter”. Create “alter.info”

name = Alter description = "This module performs several minor changes" package = Custom version = 7.x-dev core = 7.x

And create a file with the name “alter.module”. And put the following code in it with your More >

Cross browser border radius with CSS3 PIE

0

PIE stands for “Progressive Internet Explorer”. With PIE you don’t have to wait any longer to use the CSS3 border-radius property. A lot of browser already support it out of the box, but Internet Explorer only since version 9.

To also have support in Internet Explorer 6, 7 and 8 use PIE! There are two options for using it. With a htc behaviour file or with JavaScript.

Read more about it on the official website: http://css3pie.com/

Doctrine 2 i18n translatable extension

0

Doctrine 2 doesn’t have an i18n (internationalization) behaviour in the core anymore like Doctrine 1 had.

But luckily for us, Gediminas Morkevičius build the translatable behavior extension for Doctrine 2. Translatable behavior offers a very handy solution for translating specific record fields in diferent languages. Further more, it loads the translations automatically for a locale currently used, which can be set to a translatable listener on it’s initialization or later for other cases through the Entity itself.

Checkout the website: http://gediminasm.org/article/translatable-behavior-extension-for-doctrine-2

Set attribute on select option with Zend_Form

4

Today I needed to disable a few options in a status select box when building a Zend Framework application. Luckily this is very easy to do, but you just have to know how.

Make sure you set all available options first:

$element->setMultiOptions($options);

Below that line you can set an attribute on some options. For example, if you want to disable the first, second, and fith option in the select box:

$element->setAttrib('disable', array(1, 2, 5));

And you’re done!

Go to Top