Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
by
Lessons:33Length:3.7 hours
Drupal 8 1
  • Overview
  • Transcript

2.5 Generating Sample Content

As any web developer knows, it is one thing to design the layout of a site that is empty, but to make it look good when you are dealing with lots of content is another issue entirely. So in this lesson I'll cover two very important topics that you're going to need in just about every project you take on: installing third-party modules (in this case, one called Devel) and generating sample content.

2.5 Generating Sample Content

So here we are back at the home page of our new Drupal site. And we're starting to learn a little bit more about content types, how to manage, how to form displays when you're adding and editing content. As well as when you are actually displaying published content and how that's going to look to the end user. And while this is pretty simple stuff, it really doesn't tell you a whole lot right now because we don't have very much content. And in order to get a really decent amount of content it would really take quite a bit of time for somebody like you or I or an administrator or some other moderator to go in here and just start to crank out content. Even if you were generating some Lorem Ipsum text from some website Lorem Ipsum generator and copying and pasting. And putting that stuff in here to make sure that the format is right, make sure that the teasers are right all of that is going to take quite a bit of time. Well, I'm happy to tell you that when you are getting to the point where you really need to start viewing a substantial amount of content on your site, there's a much easier way to generate a bunch of content out of the box so that you can make sure that your formatting is correct. And make sure that all of those little details on your site are correct before you actually try to go live and notice that something isn't right. So the way that we're gonna do that is by going to a new administrative tab and extending our Drupal instance a little bit. So what we're gonna do is we're gonna go over to our extend tool here and there's a lot of different things that you can do here. And we've brushed over this a little bit in the past and we'll talk a little bit more in the future about installing some modules and configuring modules that either come by default with Drupal or adding some third party contributed modules. So that's what we want to do right now. We actually want to add a contributed module that's going to help us to generate a lot of data very quickly. So we can make sure that our site is really doing what we want it to do. So the way that we're going to do it is by clicking on this contributed modules link and I want to open this in a new tab. And this is gonna take us to the drupal.org website where we can now download some new modules. So I'm going to click on the search here and I'm going to search for devel. And this is a very cool extended module and that what this is going to allow us to do is a number of different things. But what we really want to do, as I said before is to generate some fake content for us and really what it's going to do is create a bunch of Lorem Ipsum content. But it's at least going to fill things out so that we can see how everything is looking. So now that we've come to this particular module, I wanna scroll down and I wanna find where I can actually download the content. And because we're running a Drupal 8, we want to make sure that we're using the Drupal 8 supported version as you can see on the top here. Now there's a couple different sections here, we have this kind of main version up here and then we have development releases down here. So at the time of this recording we are using Drupal 8 and there is a supported version of Drupal 8, so that's what we want to go with. It it shows up in the top here under normal version here then this is the one we typically wanna stick with that's going to be associated with the correct version of our Drupal installation. Now if you do see it down in development releases and not up in version that's okay. You can still download it and use it on your site but just be aware it is not fully vetted out for everything found in your version of Drupal. So if you wanna use that one on the bottom as an experiment, then that's probably fine. But just be aware that it may not be fully ready for production use. That's pretty much it, now there's a couple different ways that you can go ahead and get these modules and install them into a Drupal. You can click on these links and download them to your machine and I've shown you a way to do that before when we were updating our version of Drupal. But now I don't really want to waste time downloading these different modules and having go back and delete them if I don't need them anymore or they're just going to sit there and take up disk space. I don't really want that to happen, so instead what you can do is you can actually hover over each one of these either the tar file or the zip file and I can right click and I can say copy link address. So really all I want is the URL that this points to. So I'm gonna say copy link address and depending on what sort of browser you're using it may have different text there. It could say copy link or something along those lines but in Chrome that's what it's gonna show you. Now I'm going to go back to my Drupal instance and I now want to install a new module. So now I can come up to the top here and I can say I can install from a URL. Now if you did download it that's fine, you can just choose that file here. Otherwise I can just go ahead and paste that link in here. So this is the URL that's going to point to that tar file that I showed you. Now I'm gonna click Install and it's actually going to go and retrieve that. It's going to download, it's going to install it, and I didn't even have to put it on my local machine. That is a very nice little trick. So now what I want to do is I want to enable the newly added module, so I'm gonna click on that link. And it's gonna take me in here and I'm going to click on CORE to get that out of my way and then I'm going to come down a little bit into the development section here. Now Devel has added a couple different things in here and I don't really need all of them all. All I'm going to select is the first two Devel and Devel generate which is going to be the important one that I want to use. So then I'm going to go down to the bottom and I'm going to select install and it's going to install those two modules. And if everything has gone correctly, you should at the top of the page, see a green box that says two modules have been enabled. That's exactly what we want to see. Now in order to use these, we're going to go to the configuration tool and we are going to go down to the bottom here under development and we now see generate content and that's where we want to be. So let's go ahead and generate some content. Now at this point it's going to say what type of content would you like to generate? Well it's going to list all of the available content types. So we have three in our instance right now but if you've created more content types you'll see other things here as well. And you can choose what types of content you would like Devel to generate for you. So I am going to select Articles and My First Content Type just so I can get a couple different versions of some data out there. Now there's a couple different options here as well, I can delete all content in these content types before generating new content. So this is very useful when you are just getting your website started. And lets say, I wanted to add in a bunch of articles and some of the content types and it's going to generate those for me. But what do I do when I don't want those anymore, I need to get rid of them. Well if I wanted to get rid of all of them, I would simply check this delete all content before generating new content and I would change the how many nodes to zero. So that will actually before it generates the zero amount of content types, it's actually going to delete all of the content types that I have checked here. Warning though, if you are working on a Drupal site that is already active, that's already having content published out to end users and you do this little trick, it will delete not only the generated content types but it will also clear your actual content types. So please, please, please be aware of that, this is not smart enough to know that it can only delete the content types or the instances of those content types that it created or generated for you. So big disclaimer there but while you are just working on your website, this is completely safe to to do. So I'm going to get rid of that because I'm gonna leave what I already have in there. Now you can generate as many nodes as you as would like. And nodes is just a generic way to talk about instances of content type so 50's probably fine to get started. How far back would you like this to go, well you could either say it only Now, 1 hour ago, up to 1 year ago which I think is probably good. It gives you a good mix of time frames so you can really start to play around with the way you order the data. How many numbers of comments per node, how about 2. I think it would be good to have some comments in there so you can see how those comments are structured and then the maximum number of words in the titles. Now you can leave this at 4 and it will work but you might wanna think about dropping this number down just a touch maybe 3 or I actually like 2 because this is Lorem Ipsum text. And some of the words within Lorem Ipsum can get a little long and you could run into some issues where these titles are getting a little bit longer than you may want. And then you can add a URL alias for each node, I don't think that's absolutely necessary. You can select the language we're going to stick with the default of English and let's just go ahead and generate. So this process is actually pretty quick, there you go. In just a few moments it finished creating 50 nodes and the generate process is complete. So now if I go back to content you're going to see my content list now has gotten quite a bit longer. So as you can see here, I have a bunch of different content that's been generated. I have varying degree of content types between article and my content type. Different authors, both administrative and anonymous, different statuses here and I actually think these are all going to be published for now. So you can play around with unpublishing things and then a different number of dates when they were actually published. These are just the updated dates, but we have a lot of different content here which is really good. So now I can start to see how things are laid out and I can also check the comments here. And you'll see all the comments that have been done here, so this is kinda nice. So now, if we go back to our site, we're now going to see some additional data. So we see my data that I put in here, but now we also see additional data that's been generated for us. We have articles, we have my content types, and a varying degree of those so this is really nice. We've now got a very wide variety of content here that I can now start to play with a little bit. And now we can see when we start to design the layouts and design how the content type is displayed, we now have a really good set of data that we can work with.

Back to the top