Elgg developer Ben Werdmuller gave a very quick overview on how to create an Elgg 1.0 theme as a plugin. This approach has the advantage of leaving the core code intact. It is also handy because using the plugin system makes it easy to enable and disable themes within the Tool Administration interface.
The first step is to create a folder for your theme plugin:
/mynewtheme/
Within that folder create a blank text document entitled start.php. While not necessary, it is best to create a manifest.xml file in the same directory. This file gives a little information about your theme. Here is an example:
<?xml version=”1.0″ encoding=”UTF-8″?>
<plugin_manifest>
<field key=”author” value=”Steve O’Connor” />
<field key=”version” value=”1.0″ />
<field key=”description” value=”This is an alternative theme for elgg 1.0.” />
<field key=”website” value=”http://www.openedweb.com/” />
<field key=”copyright” value=”(C) Steve O’Connor 2008″ />
<field key=”licence” value=”GNU Public License version 2″ />
</plugin_manifest>
Now you should have:
/mynewtheme/
/mynewtheme/start.php
/mynewtheme/manifest.xml
The next step is to add a views directory and within that a default folder:
/mynewtheme/views/default/
You changes will all reside within that directory and any needed subdirectories.
If all you have done is taken the original css.php from elgg/views/default/ folder and hacked it as suggested in the previous post, you just pop your hacked css.php into your new theme:
/mynewtheme/views/default/css.php
Your changes can go beyond just altering the css.php. Let’s go back to the elgg core:
elgg/views/default/
Besides the css,php, there are other places one can edit. One such directory of particular interest is:
elgg/views/default/page_elements
It contains the following:
elgg_topbar.php
footer.php
header.php
owner_block.php
spotlight.php
title.php
Obvious places to edit include: elgg_topbar.php, footer.php, and header.php.
Once you are done editing any of these files, you need to place copies in your theme in a way that reflects the core view folder:
/mynewtheme/views/default/page_elements
Editing the elgg/views/default/pageshells/pageshells.php file would allow you to delete elements (or add if you know how) to be displayed on the page. Again, save the edited file to your theme:
/mynewtheme/views/default/pageshells/pageshells.php
When you are done, you may have something like this:
/mynewtheme/
/mynewtheme/start.php
/mynewtheme/manifest.xml
/mynewtheme/views/default/css.php
/mynewtheme/views/default/page_elements/elgg_topbar.php
/mynewtheme/views/default/page_elements/header.php
/mynewtheme/views/default/page_elements/footer.php
/mynewtheme/views/default/pageshells/pageshells.php
Obviously, there are more modifications that can be made, but this gives everyone a starting point.
All that remains is to upload and activate the new theme. Use an ftp client to upload your new theme into the elgg/mods directory. Log in to Elgg as an administrator, Go to the Administration section and select Tools Administration. Click to enable your new theme. Now your changed files will override the core Elgg files.
That should get users started. You can do quite a bit by simply working with the css.php and packaging it as a plugin. I will continue to explore other options for customizing new themes.
Related Posts
18 comments
Comments feed for this article
Trackback link: http://openedweb.com/blog/2008/08/25/creating-elgg-10-themes/trackback/