Drupal is a great tool for people who don’t know how to code
One of the main reasons I’ve fallen in love with Drupal (over Wordpress or Joomla) is the fact that it enables site builders to do great things. By using Drupal modules you can almost build anything you want. This, because all the Drupal modules are meant to work together. With other CMS-es such as Wordpress, I always felt like the add on was a self contained piece of code. Drupal feels more like Lego. All the pieces fit together. That’s why I’ll use Drupal to recreate a website with Reddit-like functionality.
Why not use Reddit and why use Drupal to make a clone?
Reddit is great, but there are some reasons you want to clone the functionality for your own Drupal site. Consider the following:
- You want to create this functionality within an internal company website such as an intranet. In that case it’s impossible to use Reddit
- You want to have control over your content. Everything you post on Reddit is, in the end, owned by Reddit. If they ever go down or decide to quit, all your content will be gone
- You can’t get banned. From time to time, it does happen that a subreddit (or user) gets banned from Reddit. Rather this is justified or not, you can lose access to your content if this happens
First off, Reddit is a large website with 700 employees who are mostly working on improving the website every day. Thinking you can exactly copy all the functionality by your own, with Drupal, is madness. That’s why I’ll try to define what I think is the core of Reddit, namely: Creating, rating and discussing content. My Drupal Reddit clone will try to do the following:
- Making it possible for visitors to create an account
- Let users can create content which consist either of text, an image or a link
- Enabling users to up or down vote content
- Giving users the ability to discuss content by posting comments
Also, this won’t be a step to step guide, but more of a global overview of what kind of modules you would need to recreate this Reddit-like functionality and how it would all fit together.
Making it possible for visitors to create an account
Drupal core comes with great user management capabilities. Enabling users to create an account is as simple as turning a switch. Under Configuration > People > Account settings below Who can register accounts? I’ll select Visitors.
Let users can create content
I want users to be able to create content, so I’ll add an extra ‘member’ role with which I can grant users with this role specific permissions. You might think this step is unnecessary because you can also use the default ‘Authenticated user’ role. In the past, however, I’ve learned it’s best to always create an extra role for site members. This way you can take away permissions from a user without having to block or delete them. Using the Registration role module I can automatically assign the member role to any newly created user.
I’ll create a new content type called ‘Post’. This content type will the following fields:
- Text (plain, long)
- Image (Drupal core image field)
- Link (Drupal core link field)
I’ll also enable comments for this content type as I want users to have the ability to discuss the post, which is a important part of Reddit as well. I’ll set them up as detailed in this blog post on how to optimize comments for Drupal.
Next I will give users with the member role the permission to create nodes of the ‘Post’ content type. Also a menu item needs to be created to the node add form of this content type in the main menu. This way users with the member role can start posting content immediately.
Enabling users to up or down vote content
At the core of Reddit is the up or downvoting of posts. Creating a leader board displaying the most upvoted posts on top. To accomplish this with Drupal I will install the Voting API and the Rate module. Within the Rate configuration I create a thumbs up/down widget and set it to be displayed on all nodes of the Post content type. I will also set the permissions so that users with the member role can vote.
When a user of with the member role navigates to a node of the post type a thumbs up/down widget is shown. Users can now upvote or downvote the post.
Next I’ll create a view with all the nodes of the Post content type. These nodes are sorted based on upvotes, displaying the most upvoted content at the top of the list. I’ll also enable voting on this view so users can quickly browse all the posts and vote on posts.
I’ll also add an infinite scroll to this view so users can keep on scrolling and rating content without navigating to another page.
Optionally: Sort by radioactivity
Sorting this view based on average votes, can quickly become a self fulfilling prophecy. Posts on top of the list are most visible and likely to be upvoted more often. New posts don’t stand a chance because they will be displayed near the bottom of the list.
A possible solution is the Radioactivity module. With this module I’ll create an extra 'energy' field to the Post content type. When a visitor views a post, either on the node or in a view, it will get more ‘energy’. This energy will decline based on your own preferred configuration. It’s now possible to sort this view based on radioactivity.
You can even go further by creating Rules to influence the energy of a post, such as:
- Add or detract energy based on a vote
- Add energy when someone comments on the post
Note that figuring out how to get Rules to work nicely with Radioactivity can be tricky.
Optionally: Create subreddits with the Group module
Another feature of Reddit is the ability to create, and post in subreddits. This could be achieved with Drupal if you use the Group module. With this module you can create different groups in which users can post content. It’s also possible to create specific roles within this group, like a moderator. The moderator has additional permission such as deleting inappropriate posts.
Yes, you can build Reddit functionality with Drupal
As I said, it’s impossible to create a full scale 1 on 1 Reddit clone with Drupal on your own. But it’s encouraging to see how far you can get by simply using Drupal modules that are already available and without having to write any code.
If you have any questions about the above, let me know by leaving a comment. Also don’t forget to subscribe to my Drupal newsletter and/or Drupal RSS Feed.
Thanks for the article. Good example for showing the strenghs of DRUPAL!
I have some experience with Drupal and the last site I created where visitors could register became a nightmare. Despite of honeypots and Captchas, spammers and hackers registered on the site like weed.
How wiuld you secure the registration process? Apparently a mail check is not sufficient.
Would be nice to read your opinion.
Lately I've had the most success fighting spammers with the Cleantalk module/service. You do have to pay a small yearly fee (currently 8 dollars a year) but up to now it's been working perfectly for me.