Microsoft Virtual TechDays

Free Virtual Event provided by Microsoft

Modifying contact component in Joomla issue

The problem I came across when making a modification to the layout in the Joomla contact component was it wasn’t updating on the website.   I even cleared out the cache and it still didn’t work.

It wasn’t until I realized it was because of the template that I was using. Templates can override the layout of Joomla components. These are located under the templates directory structure. Normally they are under template/html/com_contact/contact/default.php (for example, here is the contact component layout).

Should we build software from the ground up?

The Open Source development community has become stronger over the last several years with some successfull products being developed including Joomla, Moodle, Open Office, DotNetNuke etc.   This raises the question of why develop a new software product from the group up? why not just build applications/extensions on top of existing open source frameworks? For example, Joomla has a very large developer community base, very solid arcitecture and a active support community.   Developers could save time by developing extensions that uses the Joomla framework rather than building a new system from stratch.  Of course, it comes down to the client’s requirements and of course a open source framework may not cater for these needs.   But in general terms, if you are ever thinking about building software to do a specific “thing”, consider what open source  (or even proprietary) platforms are available that you could build your application on top of.

Decoupled Code using SubSonic

Subsonic is fantastic when generating a bunch of classes directly from the database structure…but the issue comes when OO/Application Objects clash with relational database structures.   An idea is to use Subsonic to query the data from the database and map the data directly to a application/OO object.

A really good example following the link below is to have a Product class that has a various number of attributes.  When you query data from the database using Subsonic you can do the following:

return Northwind.DB.Select("ProductID", "ProductName", "UnitPrice")

//where Product is a Application Object.

This attempts to map the data to ProductID, ProductName and UnitPrice attributes in the Product object.

Another example is to create a new application object that inherits from your subsonic generated class.
This is really handy if you want to extend and add custom business logic.

public class PersonObj : Person //Person is the SubSonic generated class
    public void ResetSubscription()
        SubscriptionDate = DateTime.Now; //Call the SubscriptionDate database field
        ExpiryDate = DateTime.Now.AddYears(1);
        Save(); //Commit the changes back to the database

return Select()
                .From<Person>().ExecuteSingle<PersonObj>().ResetSubscription(); //Notice the PersonObj on the end


Selecting a row position within a SELECT query

I want to get the third row in a result set from the following:

ID   Name

1   A

2  B

3  C

4 D

You can acheive this by using the ROW_NUMBER() rank function using SQL Server 2005/2008.   The following code will return the 3rd record.

create table #temp
ID int,
[Name] nvarchar(50)

insert into #temp values (1,’A’)
insert into #temp values (2,’B’)
insert into #temp values (3,’C’)
insert into #temp values (4,’D’)
insert into #temp values (5,’E’)

select [Name] from #temp where ID in (select ID from
(select ID, ROW_NUMBER() OVER (order by ID asc) as [Row] from #temp) as subquery
where [Row] = 3)

drop table #temp


Name = C

JQuery Event Delegation

Came across a awesome way of handling events using JQuery’s event delegation methods.   I have a list of A tags grouped in a table, and each A tag will call a method and pass a ID based on a value in the same column of that A tag.

jQuery(“#tableId”).click(function(event) {
var $target = jQuery(, target =;
if ($target.parents(“a:first”).is(“a.editNote”)) { //Make sure that we have found the right A tag
var id = parseInt($target.parents(“tr:first”).find(“td:first a”).text()); //traverse back through the parents to view the corresponding ID which is in another A tag

This is way better than doing a typical jQuery(“a[id=editNote”].click(function) as this creates a event handler for each A tag.   Using Event Delegation like above only creates one handler which has less overhead on browsers (especially IE).

Finding PHP Executable without contacting Host Provider

Came across a interesting issue with running a script via a CRON job.   I needed to find out what the path is to the PHP executable.   I could make a educated guess and attempt to try /usr/bin/php, but I find a few ways this could be done.

  1. Use the System function and execute the ls command to find the binary
  2. Use SSH access and action the command whereis php