Elgg 1.8 Social Networking

By Cash Costello
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Social Networking and Elgg

About this book

As an updated version of the first ever Elgg book, this is an excellent resource for those interested in Elgg development due to its attention to detail, clearly written style and knowledgeable author.

- Dave Tosh, Elgg co-founder.

In his book, Cash Costello makes full use of his skills in development and communication to tackle the complex subject of Elgg social networking. This easy-to-read guide gives end users, new developers, and old pros alike a solid base to start their venture into social media with Elgg. I highly recommend it as a useful and enjoyable read.

- Brett Profitt, Elgg Lead Developer

The web is becoming increasingly social as millions of people use it to blog, share, post, 'friend', 'unfriend' (which was made the Oxford word of the year in 2009), comment, and chat. Elgg – your award-winning open source social networking engine – is tailor-made to create any social networking or social media website you can imagine.

If you want to create a social networking website from scratch using Elgg, then this book is exactly what you need.

Elgg 1.8 Social Networking covers everything you need to know about building a social networking site with Elgg. It begins with instructions for installing Elgg, continues with a guided tour of its capabilities, and finishes with practical advice on deploying Elgg on a production server. And in between, it is packed with information on configuring and customizing Elgg through plugins and themes.

This book is a learn-by-doing guide to creating your own social networking site. It includes three sample case studies on how Elgg could be used as an e-learning tool, an intranet application for organizations, and a niche social networking site. Step by step it takes you through the installation, configuration, and customization of Elgg. Valuable advice is sprinkled throughout the book to enable you to build your site like an expert.

For developers, this book provides a multitude of options. First, there is a tutorial-based section that systematically teaches you how to build plugins. Soon you will have ten plugins for use on your site in addition to all the knowledge you have gained. Second, if you prefer a quick overview, this book has an appendix that describes Elgg using the terminology and design patterns common in web development. Third, if you are interested in creating a theme, it also includes a design tutorial and a catalog of Elgg's view templates.

The book then goes on to describe what is involved in running a production website. It has sections on selecting a hosting provider, configuring and tuning the server, backing up the site, and dealing with spammers.

Publication date:
February 2012


Chapter 1. Social Networking and Elgg

The Web has become social. Is today your birthday? Your family and friends are posting best wishes right now on Facebook. Are you planning to go out for dinner? You are likely checking user reviews of restaurants on a website such as Yelp. Did you read that news article about the latest political scandal? If you did, you may have discussed it with other readers in the comment section of the online news site. The Web has always been a great place to find information, but increasingly people are also using it for social interaction.

With this shift has come a new class of web applications focused on social interactions like those described above. People are sharing and commenting on photos and videos using sites such as Flickr and YouTube. They are updating their "followers" on Twitter about their latest activities. They are using social networking applications such as Facebook to reconnect with old friends, share information about their lives with friends and family, or find people with common interests.

The rich interactions available on these social sites have raised the expectations of users for web-based applications. It is not enough to search for and view interesting content. People want to interact with it, comment on it, and discuss it with others. Incorporating social features into a website leads to users spending more time on the site.

The growth in usage of social functionality and social networking in particular, is not limited to consumer websites. Many companies are using social networking software on their corporate networks for internal collaboration. Employees can use these tools to find expertise that exists within the organization and form groups that promote sharing information across organizational boundaries. In education, social networking applications are used to help students actively collaborate on projects. Students can work together, share ideas, and discuss each other's work throughout the learning process.


Social features

As you have used social sites such as Facebook, YouTube, or Twitter, you may have noticed features common to many of them. These features distinguish this new generation of social web applications from the less interactive websites that came before them.


A profile lets users describe who they are. It can be as simple as a name and a few vital statistics such as location and age or as elaborate as a complete listing of a user's background, likes, dislikes, and interests. A profile usually includes a photo (often called an avatar) that represents the user throughout the site.


Social sites often let you "friend" or "follow" other users. These relationships define who is in your social network and are often used to control access to content. For example, a user may set the permissions on a photo so that only friends may see it.

Content sharing

Many social sites focus on sharing content; think Flickr, YouTube, or Blogger. People not only share photos, videos, blogs, and files, but they also comment, rate, and recommend.

Activity and notifications

With all this sharing and commenting, people need a way to keep track of what is important to them. An activity stream that displays the latest activity relevant to a user is one technique. A good example of this is the news feed in Facebook. E-mail notifications are another common method for staying updated on what is happening.


Not only do people form relationships with other users, but they also join groups organized around shared interests or purposes. These groups often mirror the communities that people join outside of the virtual world of the web: alumni groups, sports fans, book clubs, and charities. Social websites enable these groups to form and thrive regardless of the location of the members.


Social interaction on these websites is not limited to commenting and sharing content. Encouraging communication between users is another important attribute—whether in public such as a message board or discussion forum or in private with real-time chat or e-mail-like messaging.

These are the types of features that are expected in today's websites. This expectation has created a demand for frameworks and web applications that provide social functionality. Solutions range from hosted social networking sites from providers such as Ning, to sets of plugins that extend content management systems such as Drupal and WordPress, to full application frameworks focused on social networking such as Elgg. The end result is that it is easier than ever to create custom social networking websites.


What is Elgg?

Elgg is an open source platform for building social websites, especially social networking sites. Now that sentence may require some parsing, so let's start with the fact that it is free open source software (FOSS). This means you are free to use it however you want, free to modify it, and free to redistribute it. Its development is managed by the nonprofit Elgg Foundation and developers from all over the world contribute code to make Elgg better.

Elgg is used to build social websites. It has social networking in its DNA and provides all the social features mentioned in the preceding section. Think of the buzzwords that you associate with social media: blogging, sharing, tagging, friending, or tweeting. Elgg does all of that.

Elgg is a platform that provides the building blocks for creating great social websites. While you can install Elgg and immediately begin using it as a social networking site, most of you will want to customize it. Those of you who are not developers can download plugins to change the look and feel or add new capabilities. For the developers, almost every part of Elgg can be customized by writing new plugins.

The recommended server configuration for running Elgg is called a LAMP stack. This stands for Linux, Apache, MySQL, and PHP and is the most common hosting environment on the Web. Linux is the operating system, Apache the web server, MySQL the database, and PHP is the server scripting language. Elgg can also run on other operating systems such as Windows or Mac OS X and with other web servers.

With some basic experience setting up web applications, you can go from downloading Elgg to having a functioning social networking site in 10 minutes. After it is installed, you will spend time evaluating it, testing different plugins and themes, designing your site, and building new plugins (if you are a developer). This book serves as your guide to the process of creating a site like one of those shown in the following screenshot:


The Elgg engine

The Elgg platform is divided into two parts: a core engine and plugins that extend that engine. The engine contains the basic building blocks needed for a social website. It also provides the framework for developers to create new social tools through plugins. Here is a quick overview of what the Elgg engine does for your site.

User management

The Elgg engine handles basic user account creation and management. Registration, logging in, password resets, and e-mail address changes are all handled for you by the engine. Elgg also supports external authentication so that sites can integrate user accounts with other services. For example, there are plugins available that use this capability to enable users to log in with their credentials from Facebook or Twitter.

Privacy controls

Users want to control who has access to their data and the Elgg engine does this through a granular permission system. Every piece of content in Elgg has an access level assigned to it. It could be a blog post, a video, or an individual profile element. The engine gives users tremendous flexibility in who can see their data through simple privacy controls and custom access lists.


The engine has all the hooks so that you can do anything from tweaking the default theme to writing a completely new one. You have control over every line of HTML, every layout, every CSS statement. Chapter 9, Theming Elgg describes how to theme Elgg.


It is no fun to share your latest vacation photos without people commenting on them. Elgg has a built-in commenting system that can be applied to any content in the system, whether blogs, bookmarks, or videos. This is great for plugin authors because they do not have to write any code to handle comments. It is also good for you as the commenting system looks and works the same way throughout the site.


A feature common to social sites is tagging. Tags are keywords attached to content. When you click on a tag, it shows you all the content that shares that keyword. Elgg has a common interface for tagging content—whether blog posts, files, or a user's profile. The engine also makes it easy to create tag clouds.


Widgets are draggable, customizable components that are often found on web portals such as iGoogle or My Yahoo!. Many of the plugins that are distributed with Elgg have their own widgets that can be placed on a user's profile page. The widgets display members' latest blog posts, who they are friends with, or what groups they have joined. Most social media sites provide bits of JavaScript that can be used to create new widgets within Elgg. For example, there is a widget that displays a user's latest tweets from Twitter.


Your users may not all speak the same language and you might want your site to support their native languages. The Elgg engine can load different language files based on user preference. By default, Elgg's engine and the bundled plugins come with English language files. People in the Elgg community have created translations for languages ranging from German to Chinese to Basque.


A challenge for any social site is how to keep people coming back. E-mail notification is one popular technique that Elgg supports. Another option is providing RSS feeds so that users can monitor activity on your site. The Elgg engine can turn almost any page into a RSS feed. Do you want site-wide activity? There is a feed for that. How about the latest posts in a group forum? There is a feed for that. Looking to stay updated on the newest comments on a blog post? There is a feed for that, too. Just look for the orange feed icon at the top of the sidebar menu or in your web browser's location bar.

Web services

A majority of Twitter's traffic comes from desktop and mobile clients. How does this work? Twitter provides a web services API so developers can write applications such as TweetDeck, which interfaces with Twitter. The applications can pull the latest tweets out of Twitter and can post new tweets for the user. Elgg has a framework for building web services APIs much like those of Twitter or Flickr. Think of all the possibilities: desktop clients for notifications, mobile clients for sharing photos, mashups that use your site's data.


The power of plugins

We just reviewed part of the functionality of the Elgg engine, but you probably noticed that there was no mention of blogging, status updates, or other features common to social networking sites. That is because these features are offered through plugins. The plugins modify or extend Elgg giving you control over what features are included in your site.

Bundled plugins

Elgg is distributed with a set of plugins which are written and supported by the Elgg development team. These are called the bundled plugins. These plugins provide enough functionality to run a basic social networking site and are a good demonstration of what is possible using Elgg's plugin system.

The bundled plugins provide a wide range of functionality. Included are content sharing plugins such as blogging, social bookmarking, and file sharing. There are plugins for user profiles, activity streams, groups, and notifications. Integration with Twitter, private messaging, search, and administrative tools are also provided through these plugins. Detailed information on the bundled plugins is included in Chapter 3, A Tour of Your First Elgg Site, Chapter 4, Sharing Content, and Chapter 5, Communities, Collaboration, and Conversation.

Third-party plugins

As an open source project, Elgg has a community of developers who build plugins for their own use and then share them with other Elgg users. These plugins are referred to as third-party plugins and many are available from the plugin repository on the Elgg website (http://community.elgg.org/pg/plugins). Some of these plugins add significant functionality to Elgg such as a photo gallery or event calendar. Others extend a bundled plugin or customize an aspect of the Elgg engine. There are hundreds of third-party plugins available. Chapter 6, Finding and Using Plugins describes a few of the best and gives advice on how to select and test any plugin.


The look and feel of Elgg is controlled by the theme. Elgg comes with a default theme that you can use. It is not a separate module that can be uninstalled, but is built into the engine. To change the theme, you install a theme plugin that overrides parts or the entire default theme. Theme plugins are installed just like other plugins and have access to the same APIs. Chapter 9 provides information on where to find themes for download, describes the components of a theme, and includes a guide to creating your own.

Building your own plugins

You can build your own plugins to customize or extend Elgg. Writing a simple plugin requires either basic knowledge of (or the motivation and persistence to learn) both PHP and HTML. An example of a simple plugin is one that changes the word "blog" to "report" in the blog plugin's menus and page titles. Creating a plugin that does this is quite easy to write. There is a tutorial in Chapter 8, Customization Through Plugins that shows how this can be done.

A more complicated plugin is one that modifies how Elgg handles the creation of "friend" relationships. Elgg's default model is that any member can friend any other member without requiring a confirmation. A one-way relationship is formed, meaning that the fact that I am your friend does not imply that you are my friend. This is consistent with Twitter's model of followers. For your social networking application, you may want two-way relationships that require confirmation as Facebook does. The plugin would hook into Elgg's engine and change the relationship creation process. A reciprocal friendship plugin like this is available in the Elgg community plugin repository.

With the right development skills, you could also write a plugin that adds a significant new capability to Elgg or integrates Elgg with another open source web application. Elgg's plugin API is quite powerful so the only limitations to what you can build are your skills, time, and creativity.


Case studies

To get the creative juices flowing and as a demonstration of how Elgg can be used, consider the following three case studies.

Niche social network

James wants to create a social networking site for tango dancers around the world. He wants his users to be able to upload tango music and playlists. They can upload videos of tango dancing and rate them. Each city will have its own group where members can discuss tango related activities. The groups should have a calendar that lists the upcoming dances and a place for people to post photos of previous events. James also wants to pull in posts by tango bloggers from outside his site and redistribute them as a feed to make it easy for people to follow what people are saying in the community. He, of course, also wants a slick theme that elicits the emotion of the dance.

Designing and building the site

James has selected Elgg to run his site. As he looks through what plugins are available, he sees that there is already a file sharing plugin with an extension for playing MP3s in the page. He decides to rename the default blog plugin to playlists so that people can create and comment on them. James is delighted when he sees a video plugin that uses the Kaltura video site as the backend. This means the videos will not be stored on his server, decreasing his storage requirements.

For the city-focused groups, he uses the Elgg group's plugin in combination with plugins that provide an event calendar and a photo gallery. He likes that the gallery plugin provides photo tagging and hopes that the tagging notifications gives people a reason to keep coming back to the site. He still needs to figure out how to pull in the blog feeds of tango bloggers. He finds a plugin that displays RSS feeds on user profile pages, but it requires additional development to make it do exactly what he wants. He happens to have a friend with PHP experience and with a little free development help; he now has an aggregated tango blog feed.

With theming he has two choices: either download a free theme and modify it to fit his needs or contract with a web designer to build one for him. James decides that the visual interface is too important to skimp on and uses a freelance designer.

Deploying the site

The only step left is convincing people to use his site. James has been smart. By resyndicating the blog feeds he has won the favor of the bloggers who now link back to his site. He also recruited a few well known dancers from key cities to join. James's final step is to contract a developer to create an invitational system plugin. Each member gets a limited number of invites and the only way to join is to get an invite. This helps to create a buzz about the new tango site.

From this example, you not only see how James used Elgg but also that creating and growing a social networking site is more than software. A common mistake is spending a lot of time building a site and forgetting about the challenges of getting people to use it.

Plugins mentioned

Four of the plugins mentioned are distributed with Elgg: file sharing, MP3 player (zaudio plugin), blogging, and groups. The Kaltura collaborative video plugin by Ivan Vergés, event calendar plugin by Kevin Jardine, the Tidypics photo gallery plugin by the Tidypics team, and the Simplepie RSS feed plugin by Cash Costello are all available from the plugin repository on the Elgg website.

Corporate intranet

Imagine a theoretical company called Acme Corporation. Acme has deployed applications on their intranet to encourage collaboration among their employees. They are using MediaWiki as their wiki and Sharepoint for file sharing. Management and the employees are not satisfied with the current solution. They still feel that it is difficult to find the right person with the right expertise for a project, quickly organize ad hoc teams, or form communities of practice that cut across organizational boundaries. They need software to tie together the current intranet applications while providing the social functionality needed to address the mentioned limitations.

Designing and building the site

The collaborative software team decides to create a prototype with Elgg to evaluate a social networking solution. The first requirement is that the users need to be able to log in using their Active Directory credentials. Fortunately, there is already a LDAP plugin available and with a small amount of configuration, it is up and running. The second requirement is supporting the formation of communities of practice. The group plugin distributed with Elgg provides this capability and it is activated on the development server.

Next, on the list is user profiles to help with the challenge of finding expertise. The profile plugin that comes with Elgg has tagged profile fields, but the development team felt they needed a more powerful and extensible profile capability. A third-party plugin that extends the profile plugin to provide profile types and more customizable profile fields was found on the Elgg community plugin repository.

Integration with MediaWiki and Sharepoint are the remaining requirements. Another organization released a MediaWiki plugin that pulls content out of the wiki and makes it available within Elgg. That was a quick solution, but integration with Sharepoint proves to be more difficult. After some research, they decide to write a custom plugin to use Sharepoint's web services API. The developers end up tying in updates on files in Sharepoint to the activity stream provided by Elgg. Now users can get updates on anything that is happening in the wiki, Sharepoint, or Elgg in one place.

A few of the developers have been using Twitter so they try out Elgg's microblogging plugin. The team likes its ease of use and the ability to share quick status updates, so they decide to include it in the production system.

Deploying the site

Before making the site available, the development teams decides to create accounts for all the employees first. They write a plugin that extends the LDAP plugin that grabs all the users from the Active Directory server, creates the accounts, and fills in some of the profile fields. To speed adoption of the new application, particular communities that would benefit from the groups capability are targeted. Very soon there is an active group for Java developers with shared code snippets and discussion threads on unit testing, distributed versioning systems, and many other topics.

Plugins mentioned

Core plugins mentioned were groups, the wire (microblogging), and profile. The profile manager plugin by ColdTrick IT Solutions is available from the Elgg community plugin repository. The MediaWiki integration plugin written by the MITRE Corporation is also available there. The LDAP plugin is available from Elgg's github account (https://github.com/Elgg).

Educational collaboration

Mr. Harris teaches middle school history and wants to use collaborative technology for a group project idea that he has. He needs a web-based application that is simple to set up and requires minimal configuration. Mr. Harris wants the students to break up into teams, research a historical figure, and then create an online profile for that person. The profile will include biographical information along with status updates and blogs written from the perspective of the historical figure. He also wants the students to use the site to collect resources and collaborate on the writing process.

He decides the tools he needs are blogging, groups, bookmarking, and collaborative document editing. Another requirement is that the students need to be able to access it at home and school, but no one else on the Internet should be able to see the data. One last requirement is that it must be cheap—preferably free.

Designing and building the site

Mr. Harris was recently at a conference on online collaboration in the classroom and remembers Elgg being mentioned. As he looks through the plugins, he sees all the tools that he needs. Blogging, groups, profiles, status updates, and social bookmarking are all available.

The teams will use the social bookmarking plugin to save and share online resources. The pages plugin will be used by the teams to collect the information they have gathered, both Internet and book based, in one place before they create the profile or write the blog posts. Mr. Harris likes that the pages plugin records who has been working on each web page so that he can see who is contributing to it.

The last piece is making the site a walled garden so that only students and school staff can log in and see the data. Fortunately, Elgg got its start in the educational arena and has that feature built-in. Because Elgg is free open source software, Mr. Harris was able to do all of this without any cost other than his time.

Deploying the site

The school IT staff installs Elgg on a server. Mr. Harris creates a spreadsheet with all the students' information and uses an importer plugin to create accounts for them. The experiment is a success. The students like working in an environment that feels like Facebook and are comfortable using these types of tools. A few of the blog posts that they wrote are quite entertaining.

Plugins mentioned

The pages, groups, blog, bookmarks, profile, and the wire (for user status) plugins are all bundled plugins distributed with Elgg. The user importer plugin is available from the Elgg github account.


Elgg resources

There are many resources available on the Web to help you use Elgg. Most of these live on the elgg.org domain that is run by the Elgg Foundation.

Elgg community

The Elgg community site (http://community.elgg.org) provides a place for Elgg users and developers to interact. There are group forums where people can ask questions and share expertise. The plugin repository at the community site has hundreds of plugins that have been contributed by developers.

Elgg wiki

A great place to go for documentation on Elgg is the wiki at http://docs.elgg.org. It covers the installation process, administering an Elgg site, and creating plugins using Elgg's API. The wiki also contains a list of sites based on Elgg which can provide inspiration on what is possible with Elgg. Remember that it is a wiki so you can add to it.

Developer resources

The Elgg project uses Trac for bug tracking and managing release milestones (http://trac.elgg.org). The latest development version of the code is found on Github (http://github.com/Elgg). For Elgg developer community communication, try out the Google group (http://groups.google.com/group/elgg-development) and the Elgg IRC channel: #elgg on Freenode. To keep up with the latest efforts of the Elgg development team, follow the blog at http://blog.elgg.org and the @elgg Twitter account.


A few words of advice

Throughout the book there is practical advice gained from experience building, developing, maintaining, and administering Elgg sites. Before you begin installing Elgg in the next chapter, take a little bit of time to read the general, but important advice below.

Take notes

As you work through the next few chapters, you will notice things that you would like to change or add. Jot those down in your notes so that when you are done, you have a list of possible customizations to prioritize.

Save resources

As you try out Elgg, you are going to be using the resources listed above. You will find interesting tutorials or hints about Elgg that you won't need to use at that moment. Save links to those resources—whether through browser bookmarks or web-based sites such as Delicious. In addition, as you browse the Web, you are going to run across features or design elements that you really like on other sites. Save those, so they can serve as inspiration as you design your site.

Be methodical

It is tempting to go to the Elgg community site, download 10 or 20 plugins, and install all of them at once. This is not a good idea. If one of the plugins causes a problem with your site, you will not know which the bad one is. It is better to systematically install and test one plugin at a time. Chapter 6 walks you through the process of finding, installing, and configuring plugins.

Finding help

Whether looking for guidance on how to do something or help fixing a problem, the best first stop is the Elgg wiki. Do a search there or check out the FAQs. If you do not find your answer, visit the Elgg community site. Search the forums to see if anyone has asked the same question before. If not, select the group that best matches your issue (often the Technical Support group) and ask your question. Be sure to use a descriptive title and provide plenty of details.


Using Google search with the Elgg community site

The search built into Elgg is not bad, but is not nearly as powerful as Google's search engine. You can search the Elgg community forums by including site:community.elgg.org in your Google search query.



The growth of social networking and other social media sites will be a continuing trend. Elgg is a powerful open source platform for building these types of websites. The combination of the core social engine and the customization offered through plugins provide the capabilities and extensibility needed for today's social websites. This chapter was a quick introduction to what is possible with Elgg. The following chapters give you hands-on experience with Elgg by guiding you through the processing of installing and using this software.

About the Author

  • Cash Costello

    Cash Costello performs research for the Johns Hopkins University Applied Physics Laboratory. In addition to his work there in computer vision and machine learning, he coordinates a team of developers in the creation of collaborative web applications. Cash is also a core developer of the Elgg Social Networking framework. He is active within the Elgg community, whether sharing his plugins or helping others to get the most out of Elgg.

    Browse publications by this author
Elgg 1.8 Social Networking
Unlock this book and the full library FREE for 7 days
Start now