The lesson this week has got to be “Profiling is a Good Thing”. While working on the new Elgg community site this week, it quickly became clear that the way the River code was written was horribly inefficient.

So, I had to optimise it.

Unfortunately this necessitated a schema change to the system log (a good test for the Elgg update scripts). It also required some changes to the way the river views are constructed.

The details of these changes are documented over here. Turns out to be a bit of a blessing in disguise; letting us speed up the river while at the same time increasing the number of events a plugin can hook into as well as standardising the views hierarchy.

The down side is that after the upgrade site rivers will appear to be blank – this is because while the system log is still there, the format of the log and the way the river code hooks into it has changed.

The change also means that plugins which hook into the river will also need to modify their views hierarchy slightly.

Themes for Elgg are both extremely easy to develop and incredibly powerful. Using themes you can completely change how an Elgg install looks and feels (and even behaves).

Since there has been a fair amount of discussion of themes on the groups, I thought it would be a good idea to write a brief post about it.

Themes use two key Elgg concepts – namely, the plugin architecture and the views system.

By far the easiest and flexible way to make a theme for Elgg is to build it as a plugin. This makes it easy to distribute (since they are self contained) and lets you turn the theme on and off from the admin panel (making the theming process far less invasive!)

What you must first do is create a new plugin directory under /mod (documented here). In a nutshell; create a directory in the name of your theme, a new start.php and a new manifest.xml.

Once you’ve done this you then can start modifying views. This can be done either by extension or by view overriding.

View extension
The first way is to add extra stuff to an existing view via the extend view function from within your start.php’s initialisation function.

For example, the following start.php will add mytheme/spotlight to the already existing site spotlight:

<?php

function mytheme_init()
{
extend_view('page_elements/spotlight','mytheme/spotlight');
}

register_elgg_event_handler('init','system','mytheme_init');

?>

View overriding
The next method is to override an existing theme, completely replacing it with the one provided by your plugin.

View files provided by plugins automatically take precedence over views from the core. So all we have to do to entirely replace the existing spotlight is to create a new spotlight.php in the appropriate hierarchy.

So, if the original view is stored in:

/elgg/views/default/page_elements/spotlight.php

We need to create the file:

/elgg/mod/mytheme/views/default/page_elements/spotlight.php

Now, when we go to the admin panel and activate our theme the spotlight will be replaced by whatever you put in that file. Simple eh?

You can of course do this with any view.

Using a combination of these methods means you can replace the entire look and feel of a site very quickly indeed, although I would suggest that you start slowly since many views do some quite complicated things.

It has been a few weeks now since we released Elgg 1.0, and its really gratifying to see that the forums are alive with discussion. People have been busy hacking on it, writing plugins and contributing bugfixes and enhancements back – including translations for French and Spanish already well on the way.

You may have noticed we have been a little bit quiet since the launch. This is because – since we had been in crunch for so long – we decided to just take a step back and let the dust settle from the launch and focus on some other bits and pieces we wanted to work on.

One of those is of course OpenDD, and I’ve been working on some rather fun demos and some (hopefully interesting!) technologies. Some of the other guys have been working on some other cool stuff – including our liveshouts project which is getting a fair amount of attention.

Now we are looking towards the Elgg 1.1 release and addressing some of the issues which have come up in discussion, including a few core enhancements. Pete has also developed some absolutely fantastic looking themes (which will show how easy it is to drastically change Elgg!)

We are also looking at working on the infrastructure a bit – including some more documentation and guides to writing plugins and customising the look and feel.  We also really want to work on ways to help make community contributions easier.

So, a lot of work ahead… but it should be worth it!