Skip to main content

The Cheeky Monkey Media Blog

A few words from the apes, monkeys, and various primates that make up the Cheeky Monkey Super Squad.

Send your content to social networks

How to automatically send your content to social networks

A few months ago I was asked to help manage our company blog. As a busy drupal developer, I had little time to post all of our new blog content on every social media site. So I decided to automate this so I could spend more time on client projects.

My first step was to look around and see what was currently available. Although there was some options, I found them to be a bit heavy for my application.

One of the things I was looking for was to be able to choose what social networks our content would be posted to. For example, I wanted to be able to choose to post this page to facebook, but not twitter, or post this to all social networks.

So I decided to build my own solution and here is how I did it (or just download the code from github).

Required Drupal Modules:

  • Taxonomy
  • Views
  • Features (if you're downloading the code)

Add New Taxonomy Vocabulary

Post To Social NetworksThe first step is to create a new taxonomy vocabulary called “Social Networks.” This will allow us to associate a social media site with our content. Next, we will want to add a few terms, like Facebook, Twitter, Google Plus and LinkedIn.

Now that we have our taxonomy setup, we need to add a new field to our blog content type. To do this, add a new term reference field called “Post To Social Networks.” Although you can use whatever widget you think would work best, I went with the check boxes/radio buttons option. Make sure to select the “Social Networks” vocabulary and the “unlimited value” option.

You will probably want to make sure this new field is not displayed on the actual post, so go to the manage display page and set this field to “hidden”.

Next, we will need to create some dummy content to work with or edit some existing posts. Once we have some content tagged with our social media sites, we then turn to views and create a new feed.

Configure Views and Social Feeds

CMM Social Feed Views

Next, we will need to add a new relationship to our feed (we will need this for our argument).  Add the “Taxonomy terms on node” relationship and select the vocabulary that we created in the first step, leave the other settings default.

Now for the fun part, we will need to add a contextual filter. Add the “Taxonomy term: Name” filter and make sure to use the term relationship that we just setup. Under the “When the filter value is NOT in the URL” select  “Provide default value” and choose “taxonomy term id from url”.

Now that we have our contextual filter setup, we need to set the feed path. I decided to use social-feed/%/rss.xml. The % is the argument, so this would be replaced by the term name (facebook, google etc.).

Send Feed To Social Networks

Hootsuite add rssSo now that we have our vocabulary and RSS feed setup and working well, we need to be able to send these feeds to various social networks. We could create our own api call to each social network, but that would be a bit more complicated for this tutorial. Instead, lets use a service that’s already built.

Some options to choose from include; If This Then That (IFTTT), Buffer, and Hootsuite. My decision was easy, our company already had a hootsuite account, so I logged in and went to work. This part is fairly easy; go to settings and select “RSS/Atom and add a new feed.

Now add the feed URL that we configured ealier using views ( select the network to send the feed to (Facebook, Google Plus) and your done. You will want to repeat this step for each social media site.

Now, if you have everything setup properly when you add a new blog post, it will be posted on all your social networks. Finally, you can breathe easy and thank me for all the time I just saved you and your clients!

Web Development

Would you like to know more about what we do?

View Our Services

Graphic Design Cheeky Monkey

Have a look at some our client work

View Our Work

Cheeky Monkey Discovery

Learn more about Cheeky Monkey Media

About Us