Drupal 8 Theming - Part 10 - Creating and Displaying Content Types and Fields

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello this is even for watch and learn comm and the previous episode we talked about view zoom we made an introduction to views in this episode we are going to talk about one more killer feature of Drupal and those are content types and fields as you will see content types and fields are very powerful so let's talk about them for a bit so if we go to structure right here we can see that we have this link called content types if you watch my previous videos about a wordpress custom post types this will be very familiar to you so content types are basically custom post types for Drupal except Drupal had them way before WordPress so in the version 6.0 I didn't work I didn't do anything on the version 5.0 of Drupal but on the version 6.0 content types weren't in the core of Drupal but in the version 7 they were just like the views made it to the core of Drupal in version 8 so and that module for making content types work was called CCK so when you made a drupal 6 site the first thing you would do you would install CCK module and you install these module so content types are just dead there are types of content that you want on your site so let's create one if we go to content types we can see that we already have two content types articles and basic page actually article and basic page okay let's set another content type so as in previous example we're just going to name these quanta types movies movies so is we are going to make some list of movies title field label will bill title preview before submitting optional and okay seven manage fields so this is it we created the content type now the other part of this content types are of course fields so they're like custom fields in WordPress as you can see we already define the title field you have to have it of course and we have body field as you can see we already got it with just making another contract because quanta type has to have body field okay let me see okay it doesn't have to have body field we can delete it let's add a new field and select field type we're just going to say let me see right here not list text plain long text plain just just that and we're going to give it a label of director no yes okay save and continue maximum land okay save field settings and save settings once again so we don't want to have default value for that okay let's make another field so I had a field we can just go and say explain and I'm going to actually okay a little bit explain and we're just going to call this actors seven continue save field settings and save settings okay and let's just add another field of course which will be an image field so I'm going to choose that movie poster save and continue and say from settings as you can see we have a little bit more options right here but I'm not going to go into them because we still didn't we still didn't do the part of Drupal that deals with images so for now we just go with the defaults save those settings and that's it so if we go to content right now and add new content now we have movies right here so if I click on that we will see that we have a title so it can be Inception we have some kind of body text so that would be the description of the movie and we can say Christopher Nolan I hardly DiCaprio's in that movie and I'm not going to add a movie poster right now because I don't have it so I'm just going to say save and publish of course and you can add options to your field so if we go to structure content types and go to movies actual to manage fields we can see those fields right here so we can edit them so we can for example say go to the director and say that this is a required field so we won't be able to add new movie if we don't add a director to it also we have these field settings there is data in okay so what's this telling us because we added a movie to it that there is data for this field in the database and these field settings cannot be changed so that's good to know so once you make a field and you add some content to it you can't change it anymore okay so that's the way you create new content type let's try to display our fields right now so if you go to our site on our front page actually we can see that we have this movies link right here so this is where those movies should be displayed okay so how do we do that well is enough first we just go to content and I'm going to explain why are we doing this in a second actually you will see I'm just going to delete this basic page called movies so delete content with selection delete content and click apply yes so we don't have a movies page anymore but never mind let's go to structure right now we are going to create that page but we're going to create it with views so we are going to go to views add a new view and just call this view movie list list okay don't add the description and in paid settings we are going to tell it to create a page and the page title is going to be movies with okay path is going to be movies also display format is going to be unformatted list of teasers never mind that a user use a pager okay the pager is just pagination if we have more than 10 items and that's it seven edit and now we have a page with views called movies so as you can see the path is movies so what I'm gonna do now is I'm going to go to show content the selected style of row format does not use fields so I'm going to go to show fields apply all this place okay and now we have fields so I'm going to show fields I'm going to say title title and actually no first of all we're going to go to filter criteria and say add and search for movies and as you can see let me just see this movie poster No we are going to actually search for type before because we wanna on that page we want to define a type that is going to be displayed on our page so we are going to go to type and select that type to be movies and apply to all this place okay so right now we are as you can already see in this preview we are just getting this content Inception but we wanna add some new things to it so we already have content title we're going to add a field called director so as you can see we now have those fields available to views apply all this place and apply on this place okay director and actors as you can see right here we have this apply of this place apply this place and now we have title director Ana Hector's as you can see we have on our preview right here we have title movies and the content is going to be inception Christopher Nolan Leonardo DiCaprio okay save this and now if we go to movies let's see what will happen page not found okay let's go to structure menus and go to our main navigation so edit menu okay as you can see we don't have actual movies right here because we deleted the page called movies so I'm just going to add another link right here called it call it movies movies and then link is going to be movies so we have path defined for our movies so we're just going to do that and that's it to save No okay maybe this will do okay and we're going to have home movies safe I didn't show you before but actually this one was not this previous movies that we had the right here was not going to the path of movies it was going to the path of note slash one but right now if we refresh our page we will see that we have movies right here and they are actually leading to the URL of da taming that dev slash movies so if we click that now we have Inception Christopher Nolan Leonardo DiCaprio okay great so we made a movies page okay let's try to do just one more thing so we only have one movie right here and if we want to test our site we want to have maybe many more movies of course we'll have our de Ville module which we introduced in the last episode I think so if we go to configuration generate content now we can say we can see right here that we can add we can generate content for movies so I'm just going to add maybe 10 new nodes and so that's about it okay let's just generate this and I'm going to set maximum number of words in the title to be maximally 2 and let's say generate ok so now we are going to have 10 movies and as you can see of course generate module doesn't do well very well with fields and directors and so on but as you can see we have our new ten movies and as you can see right here we have a pager so we have eleven movies with Inception so we can go to next page to display this last movie okay so this is it for this episode thank you guys for watching please follow me on Twitter or on Facebook like this video if you liked it to subscribe to my channel if you like these types of videos and we are continuing our Drupal team development in the next video thanks again for watching and I'll see you in the next one
Info
Channel: Watch and Learn
Views: 32,731
Rating: 4.9290781 out of 5
Keywords: Drupal, Drupal 8, Drupal 8 theming tutorial, Drupal 8 theming, theming, Drupal theming, Content types, fields, tutorial
Id: f-cJfwUOGMg
Channel Id: undefined
Length: 14min 37sec (877 seconds)
Published: Fri Nov 27 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.