Published by Mijingo

movie icon image

ExpressionEngine How-to Articles

Topics range from beginner to advanced, but are all born out of real world, professional, day-to-day use of ExpressionEngine. Need more information? Get training videos and ebooks on ExpressionEngine from Mijingo.

Case Study: Social Networking with ExpressionEngine, Part 1

Last week Greg posted to the Airbag blog detailing some recent projects that were hatched by Team Airbag. I thought I would point out (again, as Greg did mention this in the comments of his write-up) that three of those projects were developed on ExpressionEngine. However, I’d like to talk about just one of them right now: Clinician1.

Clinician 1 Logo in Header of Website

Clinician1 came to Airbag with the task of building a community website for Physician Assistants. A large part of the site is based around content from members of the community, comments on that content and responses to polls.

ExpressionEngine is a great tool to manage content, allow commenting on content and dozens of other ways of interacting with the content (ratings, saving or favoriting, tagging) using third party add-ons. But the client also wanted some more traditional social networking features: groups and friends. Every user had to have the ability to join a topical group and add other users as friends (in the case of Clinician1, they were called “colleagues”).

I pondered all of the ways I could implement this by cobbling together existing ExpressionEngine functionality and ultimately decided it would be easier to write both of the social networking tools from scratch, as custom modules. It was time consuming but proved easier in the long run because I have exact control over how these features act. Another benefit of going custom is that I maintain the ability to add new features to the modules and refine existing ones, based on client needs. This wouldn’t have been the case if I hacked together existing add-ons.

I created two modules: a Networks module and a Friends module. These modules are not available for download (but maybe one day), but I do want to walk through a few examples of how they are used in the templates. This part of the series we will talk about the Networks module.

Let’s start with some EE code, shall we?

{exp:networks:show type="all"}
Network name: {name}
Network Description: {description}

This is the basic networks tag pair that lists out all of the networks in the system. It displays the name, the description and then a button to join the network. The tag pair accepts the “type” parameter, which can have the value of “all” or “user.” If you give it the “user” value, the module will only return networks of which the currently logged-in user is a member.

Joining a group or network

For a list of groups or networks that the user is already a member of, we use the “user” parameter and a single variable to create a button to leave the group.

{exp:networks:show type="user"}
Network name: {name}

Leaving a group or network

There’s also the option of adding the count of network members using the {count} variable inside of the networks:show tag pair, as well as creating a permalink ({permalink}) to view the network detail page.

I also created the functionality to display a list of all members from a certain group:

{exp:networks:member_list network="1"}


as well as a way for users to create their own groups (and automatically join the new group they just created). Group creation in Clinician1 is currently restricted to the control panel and admin users, but the functionality was built to allow anyone to create a new group.

In the ExpressionEngine control panel, the networks are accessible, allowing the administrator to create new networks, edit existing networks (just the name and description) and delete networks.

Administering Networks from the Control Panel

Finally, I also added simple search functionality, so the users could search for groups to join. This isn’t part of the initial Clinician1 website, but the ability is there should it ever be needed.

This brief look at the Networks module ends Part 1 of this case study on social networking with ExpressionEngine. Next up is the Friends module, which allows users to create one-on-one connections with other members of the community.

Posted on Dec 09, 2008

Filed Under: How-To, ExpressionEngine Development,

Ryan Irelan
About Ryan Irelan

Ryan Irelan is the Technology and Development Director at Happy Cog, a web design and development firm. He is a noted ExpressionEngine expert, having created a wildly popular video training series on ExpressionEngine. Additionally, Ryan is the publisher of EE Insider, a well-known news and information site for the ExpressionEngine community. In his spare time, Ryan is the production director of A List Apart Magazine, which is one of the most popular ExpressionEngine-powered sites on the web. Recently, Ryan published a book on ExpressionEngine 2 called "ExpressionEngine 2: A Quick-Start Guide."