Drupal 8 Site Building, Lesson 31: Relationships in Views

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we want to explore the relationships that we can build between elements in our drupal website like users and nodes there are many other relationships that you might have you might build relationships between two content types you might build relationships between content types and taxonomies when you first create a view you select your base table that table might be content comments users taxonomy etc but when you select one views excludes all other tables but sometimes you need access to data associated with your base table in other tables so for instance if you choose content you might want to display user information for the author who has created that particular content item so in our next example that's exactly what we're going to do we're going to set up a view that displays a group of basic pages and when you click on the basic page the author will show up with their picture right out of the user table in our Drupal database so to make this work we need to get our data prepared a little bit head over to structure and content types and click on manage fields for basic page and we're going to add a new field for the author in this case we'll link it right to the user table click add field add a new field type and this time choose a user because we're referencing the user and this is going to be our author field so obviously we're only going to allow actual users on our site to author nodes click Save field settings and in the help text type start typing in the name of the author and when you do that of course all of the usernames will start to show up click save settings so click on manage display and you'll notice that the author label is going to be linked to the reference entity in out case that means when I click on the author's name it's going to take me to their user profile I'm going to put that in line instead of above and if you click on format' you'll notice you have a number of options here we'll leave it at label go ahead and click Save so we need some basic content here go ahead and hover over content add content and basic page this is going to be a series of fa Q's so let's go ahead and just add a basic page called all about city you can put some fake text in here it doesn't really matter just put something in here this is my node about Sydney of course the word node means nothing to our end-users so this is my answer to all the questions about Sydney all right under the author slot type the word a because we're logged in today as admin you'll notice there's a number one in brackets behind that that's just my user ID click Save and publish and there's my all about Sydney my username is linked and if I click on it it takes me over to my profile which at this point is a little boring while you're here go ahead and upload an image because that's what the point of this view is going to be just grab an image of yourself or anything else for that matter and insert one and so I've uploaded an image with my Drupal 8 hockey jersey and I've added my first name in that field that we added earlier all right we're ready for the next video
Info
Channel: OSTraining
Views: 13,207
Rating: 4.5652175 out of 5
Keywords: Drupal, Drupal 8
Id: a2052PIy7Xk
Channel Id: undefined
Length: 4min 22sec (262 seconds)
Published: Fri Jul 01 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.