The Observer Design Pattern in Joomla!

The Observer Design Pattern in Joomla!
Welcome to our new series on PHP Design Patterns in Joomla! Design Patterns are commonly accepted solutions for recurring problems in software development. The main goal is not only showing them, but also to learn why they are used and how to integrate them into your own Joomla! extensions. This series was planed as an preparation&nb...
Continue reading
Rate this blog entry:
7
5541 Hits
1 Comment

Group fields together in JForm to create html input as array

This blog post is a reply to this topic on Joomla's forum: http://forum.joomla.org/viewtopic.php?f=642&t=815225 but when I tried to post it there I got a 403 error, that is why I thought that I'll share this information here.

For the last couple of weeks I've been working on the multiple upload functionality that is going to come with the next Hotspots version. I'm about to finish this off, but as usual there are some things that pop up and need rewriting. I've decided that instead of hardcoding the generated thumbnails, I'll add an option for the user where he can define his own thumbnail dimentions.

Continue reading
Rate this blog entry:
2
4645 Hits
0 Comments

Custom filtering for JForm fields

Today I've spent an hour trying to figure out how to use custom filtering on a JForm field. I knew that it was possible, but I just didn't know how. Searching on google also didn't help much. The question was asked a year ago on stackoverflow and nobody has answered it yet.

So, I decided that I'll have to look in the code and figure this on my own. Why would you want to do custom filtering? In my case users had to submit percentages in a field. The values were stored in the database as double, so I had to make sure that values submitted for example with comma, were properly saved in the database. What I've done in the past (and I'm ashamed to acknowledge this) is overriding the controller's save function, making the changes to the form data and passing the modified data to back to JForm. Well, it works, but in this project I wanted to save time & finally do it the correct way.

Continue reading
Rate this blog entry:
4
4749 Hits
1 Comment

Specify different site language for specific page with a plugin

I had a customer who wanted to specify a different site language for their events page made with Matukio. His main language was German and he had a single page, which had to be in English. I've wasted more hours than I'm comfortable to admit on this issue and that is why I thought that I'll share the solution with you, in case you need it.

If we were dealing with a standard multilingual site, the solution to this issue would be pretty straight forward. Define a new content language, enable the language filter plugin, create a menu item for our page and set the language to English. If we go this way we run into the problem that once a user lands on the English version of the page, all links on the site will get /en appended to them. But we don't want this. We want that the links stay as they are.

Continue reading
Rate this blog entry:
0
3827 Hits
0 Comments

Get a cool compojoom T-Shirt by finding some bugs!

Get a cool compojoom T-Shirt by finding some bugs!

We are currently looking for some dedicated people helping us testing our upcoming releases and make our extensions better! New versions are bringing tons of new features and changes - and with that sadly also come new bugs and other problems, which need to be sorted out before a stable release. Because we don't want that bugs on your productive sites, we need your help!Just go to Downloads -> Development Releases, choose the extension you want to help testing with and download the latest development version. When not told elsewise you should install development releases in a "fresh" Joomla installation without prior versions installed.

As a "Thank you" the first five confirmed Bugs will get an awesome compojoom T-Shirt! (One per Person)

Continue reading
Rate this blog entry:
1
2978 Hits
0 Comments

How to use JDate

Few days ago I decided to help Yves with a datetime bug in Matukio (dating back to its "Seminar" roots). Everything seemed to be straight forward. I've worked with JDate in the past and had some experience with timezones. So I took the challenge thinking that I'll spend 2h and everything would be fine. Well, as it often happens a 2h job turned to be a one and a half day job... (this could make a very good blog post about estimates, but I'll do that another time...)

Let us examine the problem at hand. User A fills out a form, which has a field that stores a date. The best thing to do when you store the date in the db is to convert it to UTC. Why to UTC? Well this way you can have always a starting point and when you present the output to the user you can add different timezones depending on the users position. The trick here is to convert the date back to UTC. Fortunately JDate can help us with that. If you look at the JDate class in libraries/joomla/utilities/date.php you will see that the constructor actually expects 2 parameters -> the date and the timezone. So when you save a date you would generally want to do something like this:

Continue reading
Rate this blog entry:
7
45619 Hits
3 Comments