Case Study: Social Networking with ExpressionEngine, Part 1
November 13, 2008
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.
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}
{join}
{/exp:networks:show}
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.
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}
{leave}
{/exp:networks:show}
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"}
{ screen_name }
{/exp:networks:member_list}
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.
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.



Hi Ryan,
Thats really interesting, and would be a great addition to EE if you decide to release the modules. (nudge, nudge..!)
Cheers,
Cormac
Without knowing too much info on these modules, I’ll go ahead and say that I’d pay for both of these. Just to add to the nudges.
Great write up Ryan. It’s always fascinating to see how other EE developers approach certain scenarios and the tools they use. Looking forward to Part 2.
Cool overview of this topic. I think I would be even more interested in the logic of creating a module. When I’m planning a site in EE, I don’t know in what circumstances I should consider writing a module/plugin whatever. So I just think module logic and creation would be a cool topic for for one of your EE videos.
Already looking forward to the next part!
Very cool to see it extended like this.
It would be so cool if some day you released it in some form or fashion.
Sounds like a great module. I could definitely find good use for it… *cough* please release it *cough*
;)
I, like everyone above, would love to see this released (paid -or- open source - I’d pay!) not only for the addition itself, but, as Jonathan notes, the logic behind creating and integrating the module (code-wise) would be of tremendous value.
Looking forward to part two.
Thanks for posting this, and add me to the list of folks interested in these modules.
Good write-up, great site, exciting modules.
I’d willingly pay well for these, especially the friends module.
Very interesting and those modules would make a fine addition to the EE developer toolbox.
Looking forward to the next article in the series. Would be very interested in these modules of they were commercially available.