Quantcast
Channel: OlinData - web development
Viewing all articles
Browse latest Browse all 20

Of social login and view modes - Building a website A – Z (part 11)

$
0
0

Of social login and view modes, is what I want to talk about this week as social login is a very broad concept and view modes are more Drupal specific.

As always, if you want to catch up on the previous editions, you can do that through the following links:

Of social login

Social login is a concept where a user can use his or her social media account (Facebook, Twitter, Google/Gmail, LinkedIn) to register and login to a certain website. Of course, this certainly has its advantages and disadvantages. Most of the time, it is easier to actually register because a website that implements this technique will just pull the necessary information from your profile (username and email most of the times) and connect that to the website's database. A disadvantage would be that after a year, you may not remember which social media account you actually used to register to the aforementioned website.

As social login is an addition to the normal registration process, I wanted to include it. It should be as easy as possible for users to sign up for something and not bother about having to upload a profile picture again and again when you can automate that process.

It requires a few steps from the developers' side to actually implement it to a website, but it is not as hard as adding all the services yourself. I will try to give a breakdown of how to do it.

First of all, you need a module that is able to make the connections in Drupal and basically make all the settings available. There are a few options for this but I choose to use the Janrain module. (Janrain is a service that provides social login, including a Drupal module).

Installing this module is the same as you would for your regular modules. If you have trouble with it, or just don't know how, read the following manual. Next, you then have to connect it to the Janrain service, so I created a basic free account on the Janrain website.

After you have created your account, you have to copy a key to connect your Drupal Janrain module with the Janrain service. Navigate to "/admin/config/people/rpx/ and you will see the following field:

A field where you have to input your API key

You can find this key on your Janrain dashboard in a block that looks a bit like this:

This shows the application info on the Janrain website

When you have done that, you have connected your Drupal website to a social login service. You will now have a whole lot of settings in Drupal where you can fine tune how you want the social networking services to behave on your website. You can add and remove services from the Janrain website by navigating from your dashboard and finding the Quick link: "Sign-in for websites". On that page, you can choose the providers you want your users to be able to use when registering to your website.

The settings page of Janrain where it shows the different providers you can choose.

When you are finished with that (some services require you to take some extra steps to connect, but Janrain will guide you through that), you will have something like the following image:

A screenshot of the divesitebuddy login form with the social login providers

Of custom view modes

When using Views (short for: the Views module) in a Drupal installation, which is almost an essential module to have, you will run into choices you have to make regarding how to present your data. Out-of-the-box Views provide you with a few options, the most important (and the ones you will use the most) are: 'Fields' and 'Content':

Views modes in the views module

With Fields, you can output the fields you want by adding only those fields (for instance the node title) and when you save it, the View will only show the node title.

When choosing 'Content', it will use the node template system together with the settings for your content type.

Why ever choose 'Content' over 'Fields' you might ask? Just adding the fields you need and having those settings in one place sounds perfect. Well.. it makes it very hard to get certain layouts right and it will generate a whole lot of ugly markup. There is more to it but that is too much to go over in detail right now.

What I needed was a template based on a normal node template but specific for the spots; you can do this quite easily by making a new view mode. Out of the box Drupal will give you 'default' and 'teaser', which in many cases, is not enough to create your grande overview of items! So I;ve found a very easy to follow tutorial to actually.

After you have done this, you can create a .tpl (.tpl.php) file in your theme that is something like: node--spot--VIEWMODE.tpl.php and this file will only be used when you select this view mode in Views and the content type is 'spot'. So this way, I can output data more in the way that I want and with the HTML markup that I want.

That was it for this week, and if you have questions just drop me an email: richard at olindata dot com. See you next week!


Viewing all articles
Browse latest Browse all 20

Trending Articles