Installing the Using Drupal Source Code

Video loading...

  • 0:00
    [Using Drupal - 2nd Edition by Angela Byron and Addison Berry, with Bruno De Bandt]
  • 0:06
    [Using Drupal Preface 7, with Addison Berry]
  • 0:11
    Using Drupal comes with some source code
  • 0:15
    that we can use that will make following along with the lessons a lot easier,
  • 0:20
    making sure that we have all of the right code that we need in place.
  • 0:23
    So we don't have to worry about that, and we can just focus on
  • 0:26
    building the websites that we need.
  • 0:28
    So in this lesson, we're going to take a look at
  • 0:31
    what does the source code actually provide for us,
  • 0:35
    where can we get the source code, and then once we have it,
  • 0:39
    how to get it installed and set up really quickly, and then importantly,
  • 0:43
    we're also going to look at how you can switch
  • 0:45
    between chapters when using the source code,
  • 0:48
    in particular so that you don't lose any work that you did.
  • 0:51
    So once I build one of the sample websites, I don't necessarily want to lose that,
  • 0:56
    and I might want to be able to switch back and forth and take a look at that
  • 0:59
    later on down the line after I've worked on other chapters.
  • 1:03
    So we'll take a look at how to get yourself
  • 1:05
    organized with the source code and make the most use of it.
  • 1:08
    So let's get started and get that installed.
  • 1:13
    So before we actually install the source code and take a look at what's in there,
  • 1:17
    let's just quickly go over what the source code is providing
  • 1:23
    and what that means for working through the series,
  • 1:27
    and also just generally working with Drupal.
  • 1:30
    The most important thing, probably, is that the source code provides Drupal Core,
  • 1:36
    but it's Drupal Core at 7.12, not later versions.
  • 1:41
    So this is an older version that was used when the book was written,
  • 1:46
    and it also is using the contributed modules as they were used in the book.
  • 1:52
    And so again, many of the modules may be outdated as well.
  • 1:56
    And there's something really important
  • 1:59
    to understand about using this older code.
  • 2:01
    It still works, and obviously it's designed to work
  • 2:04
    specifically with how the book was written,
  • 2:07
    and you will see warnings that your code is
  • 2:11
    out of date when you first do the installation.
  • 2:13
    We'll look at that and talk about that when we go through the installation itself,
  • 2:17
    and I would recommend that you use the source code while following the lessons
  • 2:22
    that were written specifically for that source code.
  • 2:25
    Once you learn and sort of understood how the modules
  • 2:30
    or how Drupal generally works to accomplish your goals,
  • 2:33
    then you can upgrade the code and work with the latest and greatest,
  • 2:38
    and then see what may have changed or may not have changed.
  • 2:42
    It's important to understand that Drupal is constantly moving,
  • 2:46
    and the community-contributed modules and things like that are always moving.
  • 2:52
    People are always working on it; it doesn't just stop
  • 2:55
    when something works well enough, as it were.
  • 2:58
    So the source code that we have does have these older versions,
  • 3:03
    and sometimes the changes between the old version and a new version
  • 3:07
    of a contributed module are not significant at all.
  • 3:10
    You might not even notice it, but there're going to be other times
  • 3:12
    when there could be significant changes, particularly if there's a major version change
  • 3:17
    in a contributed module from, say, a 1.x version to a 2.x version
  • 3:23
    where they basically change everything—how the module functions and what it's doing.
  • 3:27
    Then there's also sometimes the module will essentially work the same,
  • 3:31
    but the UI for it has changed, your user interface.
  • 3:34
    So when we say click this thing, it might not be called that anymore,
  • 3:38
    or it might be in a different location in the settings to accomplish the same task.
  • 3:44
    So that's why we recommend using the actual source code, even though it is outdated—
  • 3:50
    much of it is outdated code—to understand the processes and understand the capabilities
  • 3:55
    of what we're building, and then you can go back and upgrade
  • 3:59
    to the latest versions of the contributed modules, and then see how that works,
  • 4:04
    and if it's changed and that kind of a thing.
  • 4:06
    That's something you're going to have to deal with
  • 4:08
    when working and building with Drupal anyway on a regular basis.
  • 4:11
    So get your foundation with what we've already set up, and then go ahead
  • 4:15
    and explore the world of contributed modules, which are constantly changing.
  • 4:20
    We also do, in the spotlight sections of each chapter,
  • 4:25
    talk about why we've chosen the modules that we've chosen.
  • 4:28
    And there's an entire series Appendix B, which is about how to choose the right modules.
  • 4:36
    And so, hopefully between working with the existing source code,
  • 4:41
    understanding the reasoning behind choosing modules,
  • 4:46
    reading and going through the spotlights, and working with Appendix B.
  • 4:51
    You'll begin to understand sort of the idea or the foundation of things,
  • 4:57
    but then how you can actually be flexible enough to use whatever tool
  • 5:00
    is the best tool for you going down the road.
  • 5:03
    The ones that we've chosen in the series may not be the best tool for your use case,
  • 5:08
    or for where things are currently in the Drupal world generally.
  • 5:11
    But it's more important to understand how these tools work together
  • 5:16
    and how to suss that out for yourself so that you then have the flexibility
  • 5:21
    to learn how to sort of cook on your own without having to use a wrote recipe every single time.
  • 5:27
    So that covers the actual source code Drupal code that you're going to get,
  • 5:32
    which is Drupal Core and the contributed modules,
  • 5:35
    all the contributed modules that are used in the book.
  • 5:37
    There are also 2 directories, one for assets and one for patches.
  • 5:41
    So assets contain things like images that we use for our case studies
  • 5:48
    so that you have something to upload and it'll match what we have.
  • 5:51
    And then we have a patches folder.
  • 5:53
    It actually only has 1 patch in it, but this is a patch for a theme that looked a little strange,
  • 5:59
    and so the patch did not get into the final version of the theme
  • 6:03
    before the book was published.
  • 6:05
    So there's a patch to correct a slight visual problem there.
  • 6:10
    So if you want to make that correction, the patch is available
  • 6:14
    so you can see what that correction is and do that.
  • 6:16
    It's not anything major that affects the actual contents of the book though.
  • 6:20
    And then once you have this source code and you're using it,
  • 6:23
    and you have all of the modules and things that you need,
  • 6:27
    each chapter has an installation profile.
  • 6:32
    Well, most of the chapters do.
  • 6:34
    Chapter 2 Jump Start does not have an installation profile,
  • 6:37
    because you're just using Drupal Core out of the box.
  • 6:40
    And what the installation profile is going to do for you
  • 6:43
    is it's just setting a site name for our case study
  • 6:47
    and it picks a theme and uses a theme.
  • 6:49
    So each of the sites for each of the chapters looks different from the other ones.
  • 6:54
    And it also creates some basic users for you.
  • 6:58
    There are 3 standard users that all of the sites have.
  • 7:01
    There's the admin user, who is essentially like user 1.
  • 7:08
    Then there's an editor user, which can have escalated privileges.
  • 7:13
    And then there's just a regular user who would be a regular,
  • 7:16
    authenticated user who's logged into your site.
  • 7:18
    And so you always have those 3 different users that you can play with.
  • 7:23
    Sometimes in a chapter, we'll ask you to log out and log in as another user,
  • 7:27
    and these are those users that you will need.
  • 7:30
    They all have the password oreilly for their user names.
  • 7:35
    Some of the chapters have additional users that they're going to
  • 7:38
    create for you as well that are referred to in the book,
  • 7:42
    and some of them will also set up, sometimes, some basic content
  • 7:46
    or frameworks for things that should exist on the site for you to work with,
  • 7:50
    but they're not the focus of what the instructions are telling you to do.
  • 7:54
    So we'll set a few things up to have in place on the site for you ahead of time.
  • 7:58
    Most of the time, though, it's just setting the name, the theme,
  • 8:02
    and creating a couple of very basic user for you, and that's it.
  • 8:06
    But we're going to take a look at what that looks like,
  • 8:09
    and we'll also talk about how you can switch between the various chapters,
  • 8:14
    because the different chapters have different installation profiles.
  • 8:17
    And so you would like to start with the correct one when you start a new chapter.
  • 8:21
    So let's go take a look at this hands on.
  • 8:24
    So to start things off, we need to actually get the source code.
  • 8:28
    So you can find the source code at usingdrupal.com.
  • 8:32
    It has a little bit of information about the book,
  • 8:35
    but the important thing for us here is there's this source code tab.
  • 8:39
    So when I click on the source code tab, there's a lot of information on this page,
  • 8:44
    but the important thing is this very first link that you see.
  • 8:47
    And just make sure that you are getting the Drupal 7 version of the source code.
  • 8:52
    If you go further down, there is Drupal 6 source code for the first edition of using Drupal.
  • 8:57
    But we want to use the Drupal 7 version of the source code.
  • 9:01
    So I'm just going to download this to my laptop, and when I do that,
  • 9:06
    I'm going to actually save it in my web root, where I have all of my little local websites running.
  • 9:11
    So you can download this and put it wherever it is.
  • 9:15
    If you have a local web server set up, you can put it into your web root there.
  • 9:20
    If you're using a development server somewhere,
  • 9:22
    you just want to put this where you want the website to live.
  • 9:27
    So I'll put it in my sites directory.
  • 9:30
    So once I have it downloaded, let's go look at what we have.
  • 9:33
    So this is my web root, and this is the zip file
  • 9:38
    that I just downloaded, or my source code.
  • 9:41
    So I'm going to go ahead and open that up,
  • 9:43
    and you'll see that we have this folder now using Drupal source 7.
  • 9:47
    And as I mentioned, there is the assets folder, so for some of the chapters,
  • 9:53
    there are things like images that you can use.
  • 9:55
    This is the patches folder for the mayo theme, if you are interested in that.
  • 10:02
    And then this is Drupal Core, this Drupal-7 folder
  • 10:06
    is actually our Drupal Core folder that we have.
  • 10:09
    By going to the site directory and look under All Modules,
  • 10:15
    you'll see the list of all of the modules that are used in the book.
  • 10:19
    And the same thing goes for themes.
  • 10:22
    And then the other thing that you'll see that's different
  • 10:25
    than just downloading regular Drupal Core, is if we go into the profiles folder,
  • 10:31
    you'll see that these are the installation profiles that we've added for the various chapters,
  • 10:37
    that you can select upon installation.
  • 10:39
    Now when I go through the installation for this, I'm not going to go into great detail
  • 10:44
    about installing Drupal, because we assume that you already understand
  • 10:47
    the basics of how to install Drupal.
  • 10:49
    If you are not familiar with installing Drupal, you should refer to
  • 10:53
    the Using Drupal Appendix A series, which is installing and upgrading Drupal,
  • 10:58
    and that gets into the details of how it all works.
  • 11:01
    So I'm going to quickly go through the installation process,
  • 11:03
    and focus on the installation profiles and how you would use those.
  • 11:07
    So if my local web server's running and I go to my web root,
  • 11:12
    you'll see that here's a link to the Using Drupal source, and here's my Drupal 7 directory.
  • 11:20
    I haven't created a database yet though, so I'm going to do that very quickly.
  • 11:23
    You can create the database however you like.
  • 11:26
    And I'm going to name the database name—well, UD is for Using Drupal,
  • 11:31
    but with the name of the chapter that I want to work on,
  • 11:34
    so that I can keep it clear, because what I'm going to do is actually
  • 11:38
    create a new database for each of the chapters, and then I can switch between them
  • 11:42
    as I like to, rather than restoring and using my database every time.
  • 11:46
    You can, again, do this however you like.
  • 11:50
    Now that I've created the database, I can go ahead and actually do my installation,
  • 11:54
    just like you normally would on a Drupal site.
  • 11:56
    Now you see when we get to this installation profile,
  • 11:59
    standard and minimal are what come with Core,
  • 12:01
    so normally I would do a standard installation,
  • 12:03
    and that's what you'd do with Chapter 2 for Jump Start.
  • 12:06
    With starting with Chapter 3, we have this installation profiles,
  • 12:10
    and so you can choose whichever one you'd like to use for this.
  • 12:14
    So if I wanted to do Chapter 3, I could select this one,
  • 12:19
    and then just proceed with my installation.
  • 12:23
    So I'm just doing normal installation, but I'm using an installation profile
  • 12:27
    instead of Drupal Core's installation profile.
  • 12:30
    I'm using the one provided by the book by the source code.
  • 12:35
    And you can see that information is already filled in for me here.
  • 12:39
    All I really need to do with this is type in the password that I want for my admin user,
  • 12:43
    and I'll go ahead and just save and continue.
  • 12:46
    And if we take a look at the new site, you can see that there's a theme.
  • 12:51
    The site name was set up, even there's a piece of content that's been added here to the front page
  • 12:57
    So basically things have been set up so that we're starting at the same place
  • 13:01
    that the book chapter is starting with Epic University's website.
  • 13:06
    Of course, the other big things that you're going to notice is this big red warning notice
  • 13:12
    about your site being insecure, which definitely can take you back a little bit
  • 13:17
    and make it feel like there's something wrong.
  • 13:19
    This is what I was talking about with the code being out of date.
  • 13:23
    We're using slightly older code, so this is Drupal Core 7.12.
  • 13:27
    There are newer versions of Drupal Core with security updates available.
  • 13:31
    So the site is simply asking you to update to the latest.
  • 13:35
    Don't do that. You should follow the source code.
  • 13:38
    Just use the source code as it is to get through the series first,
  • 13:43
    so that you get an understanding of the tools.
  • 13:46
    And then come back and you can do the updates,
  • 13:50
    and A, learn that process, which is something you definitely want to learn,
  • 13:54
    and then you can also see what changes happen between various versions.
  • 13:58
    Sometimes nothing, sometimes a lot will change.
  • 14:00
    If you go ahead and just install the latest Drupal Core
  • 14:06
    and the latest versions of the modules that we are using in the book,
  • 14:09
    some of them are going to be very different and you're not going to be able to
  • 14:12
    follow along with the hands-on tutorials in the series.
  • 14:15
    So ignore that message.
  • 14:18
    If ignoring that message makes you a little crazy,
  • 14:21
    you don't want to see that message anymore, you can turn it off
  • 14:24
    by turning off the Core Update Manager module, which is what's doing that.
  • 14:29
    That's the module that phoning back to drupal.org and looking at your version numbers.
  • 14:34
    So let's go ahead and turn that off real quickly,
  • 14:36
    and then we won't have that visual clutter going on for us.
  • 14:40
    So we just need to go to modules, and this is a Core module.
  • 14:44
    And it is called Update Manager, so I'm just going to disable this module.
  • 14:49
    I don't need it for the learning process of working on these series
  • 14:54
    and with the hands-on tutorials except when it comes to updating your modules,
  • 14:59
    in which case, once you get to that stage, you'll want to turn this module back on
  • 15:04
    because it provides a lot of handy tools for knowing what needs to be updated
  • 15:09
    and helping you add and update new modules and themes and things.
  • 15:13
    But for the purposes of learning throughout this series,
  • 15:17
    you want to stick with the source code, and you can turn Update Manager off for that time.
  • 15:22
    That's fine, it's not going to break anything on your site.
  • 15:30
    And now if I close this, you'll see that the warning message is now gone.
  • 15:35
    So it looks scary. It's really not a big deal.
  • 15:40
    It's just the nature of the beast in terms of when things were written down
  • 15:45
    and how things have changed over time.
  • 15:48
    So we'll ignore that.
  • 15:50
    The last thing that I wanted to show you is how to switch between chapters.
  • 15:54
    So that's great, I'm working on Chapter 3. I do it.
  • 15:57
    But what if I now want to move to another chapter in the book?
  • 15:59
    How do I reset my site so that I'm starting fresh, and more importantly,
  • 16:05
    using the installation profile for the new chapter, rather than just starting from scratch?
  • 16:10
    You can definitely just drop the database and start all over again.
  • 16:14
    I would recommend keeping a copy of each of the databases.
  • 16:18
    Create a database for each chapter, and then you can always go back
  • 16:21
    and review a chapter you've already done without having to recreate the whole thing.
  • 16:25
    So I'll take a quick look at 2 ways that we can do that.
  • 16:29
    The first thing I'm going to need to do though is create a new database
  • 16:32
    for the next chapter that I want to work on.
  • 16:36
    So that's simple enough.
  • 16:38
    Now that I've created that database, the way that I can switch around is by
  • 16:43
    working with Drupal's settings.php file.
  • 16:48
    So let's go ahead and open that up and talk about what's going on,
  • 16:52
    and how we can switch between these chapters.
  • 16:55
    So if I go back to the actual source code in the files and such,
  • 17:00
    if we go into the site default folder, that's where our setting.php is.
  • 17:06
    This was created automatically by Drupal when it did the installation process.
  • 17:10
    And what I'm going to do is you can do one of two things.
  • 17:14
    You can modify the settings.php file that you have,
  • 17:17
    or you could simply delete it. Whichever one is easier and works for you.
  • 17:22
    One thing to keep in mind though is that this is right protected.
  • 17:25
    When it's created, it's created so that you can't actually modify the file.
  • 17:30
    So before I try and do anything, I need to change the permissions on this file,
  • 17:36
    and you can do that however that works with the operating system that you have.
  • 17:40
    But here I'm just going to go in and I'll give myself
  • 17:43
    read and write permissions on that file.
  • 17:47
    Now as I said, I could just delete this and then go back
  • 17:50
    to my Using Drupal Source 7, then drupal-7,
  • 17:56
    and it would run the installation script again. It's a super easy way to do this.
  • 17:59
    You could also just manually change the settings.php file..
  • 18:04
    So let's go ahead and open this up and take a quick look.
  • 18:07
    If you scroll down, this is where all the database information is stored.
  • 18:11
    And so you can see that the database name is set here.
  • 18:15
    So I can change this to the new database that I just created.
  • 18:22
    And save it, because I've changed those permissions.
  • 18:25
    You get an error that you can't save it here, it's because you did not
  • 18:28
    change your permissions properly on the file yet to let you write to it.
  • 18:31
    So now that I've saved that, that's great.
  • 18:33
    So if I go back to my local host, go back to my browser.
  • 18:36
    Now if I reload this, I'm going to get an error.
  • 18:40
    It's trying to go to this site and it's not working.
  • 18:43
    And that's because the database exists, but hasn't actually been filled with anything yet.
  • 18:48
    So what I need to do is not just navigate to my Drupal site,
  • 18:55
    because it's not going to run the installation script automatically,
  • 18:59
    I need to manually force it to run the installation script
  • 19:02
    by going to the drupal-7 folder/install.php.
  • 19:09
    That's the important bit at the end.
  • 19:15
    So once I go to drupal-7/install.php, I get back to the installation screen,
  • 19:22
    and now I can choose the next chapter that I want to install.
  • 19:27
    And again, just run through the installation process, just like we did last time.
  • 19:32
    Set everything up, and use the site.
  • 19:35
    But now, if I wanted to go back to Chapter 3, I could go back,
  • 19:40
    edit my settings.php file, and have it point specifically
  • 19:43
    to the database name for Chapter 3 which was UD_Job.
  • 19:49
    And that way I can flip back and forth and not lose
  • 19:52
    the work that I've done on my various chapters.
  • 19:55
    So we've taken a look at what the source code is going to provide for you.
  • 19:58
    It's more than just Drupal Core or a bunch of modules.
  • 20:00
    It's a specific set of Core and the modules that are being used in this book,
  • 20:07
    along with a few other assets, and some installation profiles
  • 20:11
    to help you get set up at the beginning in the same place that the book chapters are beginning.
  • 20:16
    So I highly recommend that you use the source code and that you do not update
  • 20:20
    the code for security releases or update to the newest modules.
  • 20:25
    Get a feel for how things work according to what we're doing
  • 20:29
    in the hands-on sections of the tutorials, and then down the road,
  • 20:34
    you can go ahead and update things and see how they change and how they work.
  • 20:38
    We did grab the source code, we walked through the installation process real quickly,
  • 20:42
    and also looked at how we can keep a database for each chapter,
  • 20:46
    and then you can switch back and forth pretty easily
  • 20:49
    so that you don't lose all of the work that you've done.
  • 20:51
    So now, let's actually dive into using Drupal.
  • 20:56
    [Drupalize.Me]

Installing the Using Drupal Source Code

Loading...

Using Drupal comes with source code intended to be used throughout the lessons to make following the lessons much easier. In this lesson we're going to take a look at what that source code provides for us, where we can get a copy of, and how to use it. We'll go through the installation process, as well as see how we can switch between chapters in the source code without destroying work you've done on previous chapters. It is important to note that using the source code is very important if you want the lessons to match what is in the lessons. Drupal modules can change a lot over time, and the source code is designed to exactly match what is covered in the lessons. Once you've learned the basics of a chapter by working through the source code, you can upgrade your modules and explore the differences in newer versions, with the base understanding you've gained from the lesson.

Warning: Since this Drupal code is several years old, you must use PHP 5.3. PHP 5.4 or higher will not work. You will need to make sure your server is using PHP 5.3 in order to use this code properly. Many all-in-one servers, like WAMP, MAMP, and XAMPP provide older versions of PHP and a way to switch back and forth between versions.