Posted on Dec 20, 2011 in News, Tips & Tricks, Tutorials | 4 comments

Once you have installed Elgg, you’ll notice that it comes with an Elgg favicon. If you want to use your own favicon, find your plugin ”myplugin” that we already created and follow the next steps.

If you look in the folder elgg/_graphics, you’ll see a file named favicon.ico, that’s the one we want to replace. The easy way would be to just dump your own favicon.ico into the folder, but as you know now if you’ve read the previous tutorial, we do not change elgg core. So instead add your favicon.ico into the folder, myplugin/graphics.

Since the favicon we want to use is in a different locaton now, we need to track down the old favicon.ico path in order to change it. I use Dreamweaver and when I search for favicon.ico, I find the path in views/default/page/elements/shortcut_icon.php.

We are now going to override that view, by adding a view directory to “myplugin”. The view directory has special meaning to Elgg as views defined in your plugin automatically override Elgg core’s version of those views.

So add a directory called views to your plugin, in that directory create the directory default. From this level you can override any elgg view, and since we want to override shortcut_icon.php in page/elements, add these two directories. You now have a plugin structure like this,

myplugin/views/default/page/elements/

Go to elgg/views/default/page/elements/ and copy the file shorcut_icon.php and paste it into the folder elements in “myplugin”. Open shortcut_icon.php and change the path to the new favicon.ico location:

<?php
/**
 * Displays the default shortcut icon
 */
?>

<link rel="SHORTCUT ICON" href="<?php echo elgg_get_site_url(); ?>mod/myplugin/graphics/favicon.ico" />

That’s it. You changed an Elgg “view” to display an element the way you prefer. If you have any questions or comments, please leave your responses in the comments below.

If you want to create a favicon of your own you can genererate one here: http://www.favicon.cc/

The plugin “myplugin”, created in the previous tutorial and used in this post can be downloaded below.

4 Comments

  1. 12-21-2011

    I tried to install “my plugin” in Elgg version 1.7.9 and could not, gave error.

  2. 12-21-2011

    That’s because the plugin is for Elgg version 1.8. Sorry, vomorais that it’s not stated clearly. I’ll change that.

  3. 7-7-2012

    So you just copy the folder MyPlugin into the Mod folder of the Elgg installation then activate it in admin section?

    • 7-8-2012

      Yes, unzip your download and find/upload folder myplugin to mod/.

Leave a Comment

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: