This module is meant to make it easier for you to add cool social media links to your organisation - right on your Drupal Website!
Clone the repository to your system, and copy the files into your Drupal Installation at
Manage → Extend → Custom and check
Click on Install. You are now ready to start using SocialLinks.
You can configure the module to specify the URLs for the social media links in the grid.
Note: You must be an administrator for this.
Manage → Configuration → Development → SocialLinks Configuration
This will lead you to
In each text field, enter the required value (usually username) for each corresponding website.
Click on Save Configuration. You are done!
Head on to
/Social from your website to see SocialLinks in action.
For a working demo, click here.
How SocialLinks was made
SocialLinks was made entirely by me, and the only external library I used was FontAwesome for the Social Media Website Icons.
I followed some Drupal 8 Module Tutorials from the following links, to get acquainted with Drupal (as I never worked on it before) to get a start.
For reference to a simple working model to understand the skeleton of a module, I referred to Sidharrell's D8HW Example.
The module consists of the basic
.info.yml to provide information about the module while installing it,
.links.menu.yml to specify the path to be linked from Configuration section of admin pages, and a
.routing.yml to specify what should be displayed at which path (the content and the settings) and for whom.
One of the problems I experienced was that the link for SocialLinks Configuration in Configuration page was taking me to
/Socialwhere the module's content lives, not the settings - even though I had specified
The problem was finally solved when I changed
sociallinks.config(which is routed to configuration), which I had mistakenly put to
sociallinks.content(which routes to the content page).
Further, there is a GNU
README.md needed for the Git repository.
The module consists of 2 components - a controller (
sociallinksController) and a form (
The Controller contains the markup that is returned to the page. This included the
HTML markup that makes the icons and the hyperlinks, and some
<style></style> and a link to the
FontAwesome library. This code was taken from a fiddle I created myself at JSFiddle earlier.
The Form consists of the Configuration Form that allows Administrators to customize the links to be displayed. It has fields for each social media website and finally a
The problem I faced in this was to use the Configuration Settings Given in the Form within my Controller, to alter the markup according to the settings.
I firstly used
\Drupal::config('sociallinks.facebook')->get('sociallinks.facebook') (for the value to facebook)
but this returned nothing. I noticed that I hadn't imported the required modules from Drupal Core.
use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface;
This didn't work either and it finally did when I changed the above segment to
Finally, there is a
config → install to put some conventional default configuration.