Feeding Stella

.........................................................

Photo from earlier today.

Continue Reading

Avoid Drupal theme file cluttering

.........................................................

A Drupal theme may consist of several template overrides. These files are usually stored in the themes root folder. For a simple theme, this is not a problem but if you are coding a complex theme with lots of overrides of views and cck templates it starts to get pretty cluttered in your themes directory.

While working with Development Seeds excelent base theme Tao I came across an elegant solution to this. Using hook_theme we can tell Drupal that we want to store our custom template files in another directory in our themes folder.

In your themes template.php put the following function:

function MYTHEME_theme($existing, $type, $theme, $path) {
$template_path = drupal_get_path('theme', 'MYTHEME') .'/templates';
return drupal_find_theme_templates($existing, '.tpl.php', $template_path);
}

Substitute /templates with the directory name of your choice.

Continue Reading

Widgets, a Drupal module

.........................................................

Widgets is a module that enables a site editor to, on a per node basis, select “widgets” that should be displayed when viewing a node. A “widget” in it’s simplest form is just a regular node (page, story etc) but the power of the module is that you can create custom content types (with CCK) to use as “widgets”. You could say that Widgets brings the power of the block right into the node edit form.

Continue Reading

Drupal Flickr Photoset block module

.........................................................

I have previously written about creating photo galleries using the Flickr Field module. Before I came up with the solution described in the post Drupal Flickr gallery using Flickr field I developed a Flickr Photoset block module. Since I’m not going to use it nor contribute it to the Drupal contrib repository I thought I at least upload it here put it on GitHub so that anyone that might be in need of a Photoset block can use it.

The module is still in early development but fully functional. Use it at your own risk.

Flickr Photoset Module at GitHub

Continue Reading

Drupal Flickr gallery using Flickr field

.........................................................

With the Flickr module you can display images from Flickr in various ways. On thing you can’t do out of the box is to display a perticular photoset with multiple thumbnails. Say you have the content type news and every news item is associated with a perticular Flickr photoset. When viewing the news item you want to display the photoset below the node body.

Continue Reading

The Drupal module jungle

.........................................................

Drupal is a great CMS, during the time I have spent working with it I have come to love it. However, for an emerging Drupal developer the abundance of different modules can be a real hassel. Sometimes you need third party modules to perform simple tasks, such as getting the breadcrumb trail to work properly or to display a simple menu. Below you will find a list of modules I find indespensable when developing a Drupal web site. I have left out the modules Views and CCK since they are so vital to developing a Drupal site you are probably already using them.

Continue Reading

Dining in Phuket, Thailand

.........................................................

I recently got back from a two week holiday to Phuket, Thailand (actually this post has been in the draft stage for over a year). During my stay in Patong Beach, the number one turist trap on the island, I visited several restaurants. As one might expect, there are hundreds of restaurants in Patong, many located near Beach road, the main road running next to the beach, and some hidden away on the second floor of some obscure pub. It took me a few days to figure out where the real gems lay hidden and I ate some pretty crappy food before I found them and I can tell you this – there are no respectable restaurants on Beach road.

Continue Reading

Reading a XML processing instruction with PHP

.........................................................

I’m doing some XSL transformations in a project I’m involved in right now. The XML documents that are beeing transformed all include a xml-stylesheet processing instruction that I need to read in order to know what stylesheet to use for a specfic document. To my surprise, reading processing instructions from a DOMDocument in PHP was not so easy as one might assume.

Continue Reading

Don’t miss Ubiquity

.........................................................

I installed the Ubiquity browser plugin yesterday and I’ve had some time to play around with it. Without a doubt Ubiquity is the most exceting thing that has happend to web browsers in years. I’m not going to rant about all the things this browser plugin can do for you, instead see for yourself at Ubiquity project at Mozilla Labs.

Continue Reading

Zend_Form custom/localized error messages

.........................................................

I’ve been playing around with Zend_Form and Zend Framework 1.5 these last couple of days. Like most people I hade some trouble getting used to the decorator part of the form API. Decorators are used to style form elements for rendering in the browser, adding tags before, after and wrapping the form element itself. After much swearing I finally found this article in the Zend Developer forums that did a pretty good job explaining it.

The next problem I ran into was customizing the form error messages, not just customizing the messages but also localizing them. The framework has default error messages defined for all validators you can use with your form elements but they are kind of stiff and I doubt anyone really want’s to use them. It turns out the solution is really simple.

To attach a validator to a form element you normally write something like this:

$textField = new Zend_Form_Element_Text("myField");
$textField->addValidator(new Zend_Validate_NotEmpty());

If you want to customize the message and maybe even localize it you simply init a validator and manuelly set the message via the setMessage method, like this:

$notEmpty = new Zend_Validate_NotEmpty();
$notEmpty->setMessage("You have to enter a value");
$textField = new Zend_Form_Element_Text("myField");
$textField->addValidator($notEmpty);

If you like to localize the error message, replace the setMessage call with:

$notEmpty->setMessage($this->getView()->translate("You have to enter a value"));

It’s just that simple ;-)

Continue Reading

The Blogroll

Search this Site


[]