Drupal 6: Creating and Editing Custom Themes

Drupal 6: Creating and Editing Custom Themes

with Chris Charlton

 


Drupal is widely recognized as a powerful back-end system for web sites, but Drupal 6: Creating and Editing Custom Themes shows how the application can also be used to manage the look and feel of a web site. Web architect Chris Charlton introduces the core themes that ship with Drupal. He shows how to install and administer new themes, change color schemes, and add sub-themes to existing themes. He also demonstrates how to build a custom theme from scratch; integrate HTML, CSS, and JavaScript; and apply themes to specific nodes and blocks. Exercise files are included with this course.
Topics include:
  • Setting themes and theme permissions
  • Using the Color Module to change color schemes
  • Building sub-themes
  • Adding HTML, CSS, and JavaScript to themes
  • Understanding templates
  • Applying themes to pages, nodes, and blocks

show more

author
Chris Charlton
subject
Developer, Web, CMS, Web Development
software
Drupal 6
level
Intermediate
duration
4h 12m
released
Dec 08, 2009

Share this course

Ready to join? subscribe


Keep up with news, tips, and latest courses.

submit Course details submit clicked more info

Please wait...

Search the closed captioning text for this course by entering the keyword you’d like to search, or browse the closed captioning text by selecting the chapter name below and choosing the video title you’d like to review.



Introduction
Welcome
00:00(Music playing.)
00:03Hi! I am Chris Charlton. Welcome to Drupal
00:06Creating and Editing Custom Themes.
00:08In this course, we will explore all of the tools and techniques needed to improve
00:12the design of a Drupal website by building and implementing custom themes.
00:17We will begin by building a basic Drupal website with a default theme and
00:21getting familiar with the tools every Drupal theme designer needs.
00:25I will go through how to control and build on top of the standard themes
00:28that come with Drupal 6.
00:30Then we will create a custom theme for Drupal by integrating graphics and web
00:34technologies like CSS and HTML.
00:37Finally, we will cover the specifics of applying custom designs to various pages
00:42and elements in Drupal, known as Nodes and Blocks.
00:45I have been teaching how to develop web pages for almost a decade and manage one
00:50of the largest Drupal user groups in the world.
00:53From my experience, Drupal is the most exciting web platform I have come
00:56across in my career.
00:58It is my favorite solution for building websites.
01:01So let's get started with Drupal themes.
Collapse this transcript
Using the exercise files
00:00If you are a Premium member of the lynda.com Online Training Library, or if you
00:05are watching this tutorial on a DVD-ROM, you have access to the Exercise Files
00:11used throughout this title.
00:13The Exercise Files are organized by chapter, starting with Chapter 02,
00:18Getting Drupal Ready.
00:19We will be building a Drupal theme, piece by piece, throughout this course.
00:24We have included a few items in the Exercise Files that will help you if you
00:28need to jump in somewhere in the middle of the course.
00:31Let's take a look at the Chapter 06 folder.
00:34If you need to jump in at Chapter 06, you will need to see the work in progress
00:38Drupal site and theme as we left it at the end of Chapter 05.
00:43To set that up you will need these three files.
00:47The Chapter 06 database compressed file is a snapshot of the Drupal database as
00:52we left it in Chapter 05.
00:54To load up the database file, we will need to import this file into a blank
00:59database using a phpMyAdmin interface.
01:02So I already have phpMyAdmin loaded in my browser.
01:06If you set up your Drupal site using MAMP or WAMP, and you do not know how to
01:10get to phpMyAdmin, check out Chapter 03, Installing Drupal in the Drupal
01:15Essential Training Course on lynda.com.
01:18So here we need to create a blank database through phpMyAdmin, and I am going to
01:22call this lynda_drupal_themes, and I am going to click Create.
01:27This will now create a blank database.
01:29I can click the Import tab and then browse for the database compressed file,
01:34click Open, and then Go.
01:37Then phpMyAdmin will go through that database file and actually load up all the
01:42database tables and data required for the Drupal Exercise Files.
01:47Before we leave phpMyAdmin, there's one more thing we need to add, and that's
01:51actually a database user.
01:52So I am going to click on the Home screen and then click Privileges, Add a new User.
02:00And in the User name field, I am going to name the new user 'drupaluser'.
02:05We are going to make sure that it's set for Local, Host, and I am actually going
02:09to set No Password here, because we don't need one for the local database.
02:16We need to grant privileges to this new database user, so we will actually click
02:21Grant all privileges on wildcard name for our local environment.
02:26You wouldn't want to do this grant all on, say, a web server, as that would be
02:30potentially dangerous.
02:32But since we are developing locally, this will be fine.
02:35Feel free to click Check All on the Global privileges, and then click Go.
02:40This will create a new database user, called 'drupaluser', tied to all your local
02:45databases, allowing Drupal to communicate to the database server.
02:49I already have this database user in my local system, so I am not going to
02:54click Go, but you should be able to have a database set up with a database user
02:59on your local machine.
03:00I am going to minimize my phpMyAdmin, and before I move onto the other Exercise
03:06Files, I want to show you how to load up the database using the Acquia Drupal
03:10Control Panel for Mac or Windows.
03:13If you didn't set up your site using WAMP or MAMP and instead used the Acquia
03:18Drupal Control Panel, you can actually just click Manage my database to load
03:22phpMyAdmin and follow the steps that I just walked through, or you can actually
03:28create a new site, in Acquia, using the Import feature, and then actually choosing
03:34a database dump file by clicking Browse, and then going to the Exercise Files,
03:39Chapter 06, and choosing the compressed database.
03:44I won't go through the import process here, as I already have my site set up.
03:48The Ch_6_start_lynda-drupal-themes zip is our local Drupal site files with
03:54our settings and files folder required for content that appears in the various nodes.
04:00So this file, I am actually going to uncompress and copy into my Drupal sites
04:05folder, and as we see that there would be a default folder and possibly an all
04:10folder, so I am going to actually just Copy and Paste this zip file, and then I
04:17am going to extract the folder out of this zip file.
04:21So we see that Windows has created an extra folder.
04:24We need to make sure that we only have the lynda-drupal-themes folder inside
04:29our sites all folder.
04:31Since Windows created an extra folder called Ch_6_start_lynda-drupal-themes,
04:37we will have to pull out the lynda- drupal-themes folder and place it in our
04:42drupal sites folder.
04:45So we can actually delete the extra folder and the copied zip file, because they
04:49are no longer needed.
04:50In here, you are going to see the settings file and all the uploaded content
04:55needed for our Drupal site.
04:57Going back to the Exercise Files, Chapter 06 folder, we have one more file that
05:02you will need to get started, and this is the Ch_6_start_sites-all zip, which
05:08is a copy of my local sites all themes folder, containing the theme files
05:13needed for Chapter 06.
05:14So let me Copy this file.
05:17I will Paste it into my drupal-6-sites folder.
05:21I am going to extract the files, and this time, I am actually going to extract it
05:26into the sites folder.
05:29And we see that now I have added an all folder that has a themes folder inside.
05:35And in my all, themes folder is the hanselandpetal theme that we have been
05:40building throughout Chapter 06.
05:43So going back a couple of clicks, we no longer need the zip file that I copied
05:48out of the Exercise folder.
05:49So now we have the all folder and the lynda-drupal-themes folder that contains
05:55our settings file for our drupal site.
05:58It takes a bit to put these files in place and recreate the database user, but
06:02once you do, you can pick up at the start of that chapter and follow along with me.
06:07You will see that Chapters 04 and 05 do not have a sites all zip file.
06:13That is because there are no theme files created before Chapter 06.
06:18You will also see that Chapters 02 and 03 don't have any of these files, because
06:23Chapter 04 is the first chapter that you will need to pick up from a partial
06:27Drupal site that we built in a previous chapter.
06:31In some of the chapters, you will see a few additional files that are used for
06:36various exercises we do within those chapters.
06:39I will explain, in the associated video, when you need those files.
06:43The Design Mockup folder simply has a Mockup image of our finished theme that we
06:49will refer to, within the course.
06:52Finally, there is a Completed Theme folder in the Exercise Files.
06:56The Completed Theme is included so that you can compare the theme that you build
07:01in this course to the completed theme that I built.
07:04If you are a Monthly subscriber or Annual subscriber to Lynda.com, you
07:08don't have access to the Exercise Files, but you can follow along with your own assets.
07:14Let's get started.
Collapse this transcript
1. Drupal Themes
Learning about Drupal themes
00:00Drupal is a free Social Publishing Content Management System.
00:04Some of the most popular sites today that run Drupal are popsci.com
00:09and whitehouse.gov.
00:11Drupal is popular because of its flexibility in features and front-end design.
00:15While Drupal already comes with a handful of themes out of the box, the real
00:19power comes with a level of customization available for any site or brand.
00:24Before learning how to develop a Custom Theme for Drupal, you will need to be
00:27familiar with what's already out there, and what makes a good theme.
00:31I like to also showcase some themes that I like.
00:34So the official listing of Themes for Drupal is available on drupal.org.
00:39You can click on the Themes page.
00:42They are literally hundreds of Themes available for Drupal through its official site.
00:46In fact, if I click Last, you will see that there is about over 50 pages
00:50of themes available.
00:52Themes are made up of XHTML, CSS, and some basic PHP.
00:56Themes can be flexible and have things like Sidebars go away when there's no
01:00content assigned to them.
01:02On the web there's a lot of themes available, and there's one site in
01:05particular, themegarden.org, that allows you to test-drive a bunch of the themes
01:10available for Drupal.
01:12Two themes that I am a fan of are the Zen Theme, as this is the plain white
01:16vanilla theme that allows me to build my CSS on top of Zen Structure that Zen has laid out.
01:22Another Theme that I am a big fan of is Acquia Slate by the Top Notch Themes Group.
01:28Acquia Slate is a free download and I recommend you check out the other themes
01:32also available by Top Notch, because they really are Top Notch.
01:36If I can click on the Preview link for Slate, you can see that there's a lot
01:41of flexibility, as the highlighted areas are the regions that we can assign content to.
01:47That's actually what makes a good theme flexible.
01:50You might want to take a minute to browse through the Themes available on
01:53drupal.org and see what other people built, to give you some ideas when you
01:58build your own Drupal Theme.
Collapse this transcript
Building sites today with Drupal
00:00Working with Drupal is different from building Static Websites as there are no
00:04pages to upload with an FTP program.
00:06Only Theme Files and Add-on modules get traditionally uploaded, while Alt Text
00:11and Imagery that make up a site's content are uploaded through Drupal's own
00:14web-based interface.
00:16The ways that Drupal is similar to static websites are that the Drupal uses HTML
00:21and CSS for layouts and styling.
00:23Navigation in Drupal, known as menus, are built with HTML lists.
00:28This is an Industry Standard practice for Site Navigation today.
00:32Usually a page design is broken down into high level regions, like Header,
00:37Footer, and Content.
00:39These same regions appear in Drupal Themes.
00:42If there are any areas of Drupal you are not yet comfortable with, then I
00:46recommend you check out the Drupal Essential Training available on Lynda.com.
00:51You may want to go through that course before trying to build a Drupal Theme.
00:55Probably the hardest part of learning how to tackle Drupal Themes is its
00:59terminology, like Page, Block, and Node.
01:02Understanding these terms and concepts in Drupal are essential to producing
01:06a Drupal Theme.
Collapse this transcript
Required knowledge and software
00:00For someone to produce a Drupal 6 Theme, a basic knowledge of PHP, HTML, and CSS is required.
00:08In this video, I will quickly review what skills are needed to follow along in this course.
00:13When building a Drupal Theme, a basic knowledge of HTML is required because we
00:16will be actually building Templates that utilize HTML Markup.
00:21If you are not familiar with HTML, I highly recommend the Training available on
00:24Lynda.com, titled XHTML and HTML Essential Training.
00:30CSS is also required when building a Drupal Theme.
00:33If you are not familiar or comfortable with CSS, I also highly recommend that
00:37you check out the Online Training available on Lynda.com, and I personally
00:41recommend a specific course, titled CSS2 Essential Training.
00:46I have actually viewed this course and it was one of my great introductions into CSS.
00:52PHP knowledge is also required, but only a basic knowledge of PHP Variables.
00:57If you are not familiar with PHP, or you would just like to learn about PHP
01:00Variables on its own, you can check out the Essential Training, available on
01:05Lynda.com, for PHP and MySQL.
01:08To edit PHP, CSS, and HTML code, we will need a Text Editor.
01:13One commercial industry standard option is Adobe Dreamweaver, which is
01:17available on Windows and Mac.
01:19Dreamweaver costs $399, so it is kind of an expensive option for many people,
01:25and since Drupal is free, I would actually like to offer some alternatives to
01:29Dreamweaver that are free themselves.
01:32One option I would recommend for free is TextWrangler.
01:35But it's only available on Mac, but I use it personally and it's actually a
01:39really good quick editor.
01:40I also use Eclipse, the PHP Developer version, because I actually do some more
01:47complex development with Drupal.
01:49And I am recommending Eclipse, but I am going to let you know that it's an
01:52intimidating interface for newcomers.
01:55Eclipse is also available on Windows and Mac.
01:58Now that we know what skills we need when producing a Drupal Theme, we will need
02:02to get our text editors ready to edit those files.
02:04I will be using Dreamweaver on Windows, and I have it installed and ready to go.
Collapse this transcript
2. Getting Drupal Ready
Installing Drupal 6 using Acquia
00:00Before we can do any work today, we need to install Drupal.
00:04Installing Drupal is already covered in depth in the Drupal Essential Training
00:08course, which is also available on Lynda.com.
00:12In Essential Training, Drupal was set up using WAMP or MAMP, which works just
00:16fine, but I will be installing Drupal using the new Acquia Drupal Control Panel
00:21for Windows, which is actually a very new exciting thing, because now you don't
00:26have to do any configurations to your machine to get Drupal running locally.
00:31You should know that using either method will work just fine to follow along in this course.
00:35So two things will be needed to be downloaded.
00:39The first is Drupal 6, and you can find that at drupal.org.
00:44You can just click Download Drupal, and then you will want to open that zip file.
00:49The second item to download is the Acquia Drupal Stack Installer.
00:54This is the Control Panel I was mentioning, and that's available at acquia.com,
00:59in their Downloads section.
01:01So when you visit Downloads, there would be the Acquia Drupal Stack Installer
01:05for Windows and Mac.
01:07Choose your appropriate platform, click Download Now, and then install that application.
01:12I have already installed mine on Windows, and here is what the Control Panel looks like.
01:18Everything seems to running fine, because we get the green lights for
01:21both Apache and MySQL.
01:23Essentially, Acquia Drupal's Control Panel allows Drupal to be installed easily,
01:30and includes all the necessary pieces that are required to run Drupal.
01:35So that's Apache, MySQL, and PHP, all encompassed in this one application.
01:40So to get Drupal 6 installed, I can actually just click on the localhost, which
01:46will list any of my multiple sites that I install locally.
01:50I want to click More, and by clicking More I am brought to this list of sites.
01:54I am going to click Import, because I will be creating a new Drupal 6 site, not
02:00using the Acquia version of Drupal.
02:03So you can click Import if you already have a Drupal site ready, or if you want
02:07to install something that you have been working on.
02:10So I am actually going to Browse for my files.
02:13Now, I have already put my drupal-6 folder inside my Sites folder, so I click My
02:20Folder> drupal-6, and I will actually create a new database.
02:26If you already have a database, you can import it now.
02:29So this one I will call lynda_drupal_ themes, and I will actually place it at a
02:37lynda-drupal-themes folder.
02:40And as you can see, we get a preview at the bottom of where that's actually going
02:43to live on our local machine.
02:45Notice I didn't add a .com or .net.
02:48This is not necessary as it's only going to run locally. Click Import.
02:53It's now restarting the appropriate services.
02:56Your browser's automatically open, and we are now brought to the Installation
02:59screen for Drupal 6.
03:00So I am going to click Install Drupal.
03:03So I am entering a site address that is not going to really be used since it's
03:10going to run only locally.
03:12And I have to put in a Username and an E- mail, plus a Password for my first user.
03:19So I am just going to use password as my Password.
03:24Make sure that the Default time zone settings are set, and we also want to make
03:28sure that we Enable Clean URLs.
03:30If you are not able to set these settings, then you are missing an important
03:35file called Htaccess.
03:37So make sure that you have actually copied that over.
03:39We will click Save and Continue.
03:42Now, Drupal has finished the installation, we can visit the site.
03:46Now, since Drupal is installed, we are logged in, we can now start
03:49getting Drupal Themed.
03:52Even though we use the Acquia Drupal Stack Installer here, your MAMP or WAMP
03:56setup would be just fine. All we need is a Drupal 6, fresh installed, so we
04:02can actually theme it.
Collapse this transcript
Configuring the appropriate modules for a Drupal site
00:00Drupal will need content for us to theme around, but before we can add any
00:04content, we should make sure Drupal is finished being set up.
00:08This includes enabling any modules our site will require.
00:12So let's review which modules need to be enabled and why.
00:16So to get to the Modules Administration screen, we actually need to go through
00:19the Administer link, and then Modules, which is here on the right column, and we
00:25will now be presented with a whole list of modules.
00:28Now, remember these are only the standard Drupal modules that come with Drupal
00:336, nothing new has been added.
00:36So the modules we will need are the ones that revolve around content, so that
00:41means the Aggregator module needs to be Enabled, and this will be used for any
00:46RSS feeds we would like to consume within the site.
00:49The Blog module will be turned on, because the owners of the site wish to have a blog.
00:55We will be theming that later.
00:57The Comment module should be on, especially when you are using blogs.
01:01This will allow visitors of the site to actually comment on the content.
01:06The Menu module should be Enabled as well, because we will actually be using the
01:11primary navigation menu that Drupal provides, so this module is needed.
01:16I also want you to turn on the Path module, because we want to actually supply
01:20custom URLs to all our node types that we will be saving throughout the title.
01:27The Search module needs to be on as well, because we are going to have a global
01:31search box that will appear at the top header.
01:34And the Upload module is the last module that needs to be turned on.
01:38This Upload module allows us to have file attachments on any node, as we will
01:42learn later, is how we will actually be uploading photos for the content.
01:48So click Save Configuration.
01:50And once that's done and we see that there is a success message, we can actually
01:54now move on to building the site and its content.
Collapse this transcript
Creating pages with standard node content types
00:00Drupal's main content is saved as an internal object, known to Drupal as a node.
00:06Each piece of saved content is saved as one of these nodes.
00:10This means pages and even blog posts are all essentially nodes.
00:13We will need a few nodes in our database to theme around, so I will prepare some
00:18content nodes, both page and blog types.
00:21Starting from my Administration screen, we need to visit the Create content
00:26screen, and that's available on the left side of a standard Drupal site, in
00:31the Navigation menu.
00:32So there is a link, Create content, and when you click there, you are presented
00:36three options by default:
00:38Blog entry, Page, and Story.
00:41We will not be using Story throughout the course.
00:44If you do not see Blog entry, then you have not enabled the Blog module and you
00:48should do that before arriving at this screen.
00:50I will start out by creating some blog posts.
00:54So I click Blog entry and now we need to add a Title.
00:58So I say My first blog post. I say 'Hello World!'
01:04'This is my first flower blog post.' Looks good.
01:09I am going to now make sure that my published settings are set to Published.
01:14That is correct, and now I click Save.
01:16I am going to now create a second blog post, so I will make this quick. 'Another blog post.'
01:22'Yay! More text.'
01:29Published? Yes.
01:30Save.
01:31We will do one last one.
01:41So just like the others, we make sure that they are Published, and we click Save.
01:44So now we have a few blog posts saved.
01:47If at any time you forget what content is actually saved into your system, you
01:51can refer to the Content screen, which is in the Drupal Administration, and that
01:56is actually covered in the Drupal Essential Training.
01:59If at any time, after adding content, you forget what content is in your system,
02:05then you can go to the Content Administration screen, and that's actually
02:08covered in the Drupal Essential Training course, also available on Lynda.com.
02:13So now that my blog posts are set up, we need a couple of pages that will be
02:17critical to the site, so let's go and add those.
02:19Going back to the Create content link, we are now going to add some Page node types.
02:24So click Page, and just like blog posts they both require a Title, and will
02:29probably have a Body.
02:32So I am going to add two pages.
02:34The first will be the About Us page.
02:38This will be actually a little bit different, because we are going to add some
02:40menu settings to these pages.
02:44So we are going to open Menu Settings.
02:46The menu title will be about us.
02:48We are going to leave all the other settings as they are.
02:51In the Body, I have some text in the Exercise Files, so let's go get those.
02:57In Exercise Files, Chap 02, there is some text, so we are going to grab the about text.
03:03We are going to Copy All, go back to our Drupal site, and we are going to Paste
03:08it into the Body area. Looks good.
03:10We will go down.
03:13We are going to now also expose the URL path settings, and we are going to say
03:18the URL for this node, for this page, is going to be about.
03:23Then we make sure that we Publish.
03:25And this is a little bit different as Promoted to the front page will not be
03:28enabled for pages, only blog posts. Click Save.
03:34And now we have an About Us page.
03:36In fact, the Menu Settings that we activated in creating this node now make an
03:41About Us link up here in the Primary menu.
03:45We will do this one more time for our Services page.
03:47Click Create content, click Page.
03:50We will title this 'Services'.
03:52We will also use the Menu Settings, just like the About Us page, and this will
03:57have a Title link of Services.
04:01We also prepared you some text for this page in the Ch 02 folder of
04:06your Exercise Files.
04:07So we are going to Copy, Paste. Looks good.
04:13We will also provide a URL path setting.
04:17Services will be the URL, and we make sure that the node page will be Published. That's good.
04:23Save. Now the node Services page has been created.
04:27We see up in the top right, in the Primary menu, both About Us and Services now appear.
04:32We have created blog posts and page types.
04:35These are the standard content types that we will need for our site.
04:39After setting up the blog posts and pages, you should now be comfortable with
04:43the concept of a node in Drupal and the key types, which are Pages and Blogs.
Collapse this transcript
Creating custom node content types
00:00If Page or Blog types are not good for a specific content you like to write,
00:05say for our flower shop, we can create a custom content type in Drupal called flower.
00:11This custom flower type would be used for any product page on our flower site.
00:16Creating custom content types allows a site to break up its content.
00:20And as we will see later in our course, each content type can be
00:24themed differently.
00:25So to create a content type in Drupal, we are going to actually start from the
00:29Administer screen, and click Content types.
00:32And as we see, the default content types in Drupal are already set and listed, we
00:36are going to go up and Add a custom content type.
00:39The Name is going to be Flower.
00:42The Type will be flower, but will only contain lowercase letters.
00:47The Description, we will put something simple, so we will say Flower types.
00:51We will go down to the Workflow settings, and we will open those, and make sure
00:56that both Published and Promoted to front page are selected.
01:01Attachments also need to be Enabled for Flower types.
01:05This is going to actually help us upload flower images to each node.
01:10If you do not see the Attachments option listed here, you need to enable the
01:16Upload module for Drupal. Go down.
01:20We can open the Comment settings and make sure Read/Write are set, because we
01:24would like site visitors to actually comment on the flowers they find.
01:28So closing this, closing Workflow.
01:31We can now Save our Flower type, and we see that now flower is listed with the
01:36other content types that Drupal comes with.
01:39So now that we have a Flower type set up, we can actually add some flowers.
01:44We will do that in the Create content menu, as we saw with Blog and Page before.
01:49We see now that there's a new option, Flower, and it's listed in both the
01:53Navigation menu and on the Create content page. Either will work.
01:57So we click Flower, and now we can create a flower.
02:01So our first flower will be actually titled Star Gazer.
02:07I have some text for the Body already prepared in the Chapter 02 folder of
02:11your Exercise Files.
02:13So we are going to open this.
02:16Select, Copy, Paste, and now we have some content for our flower.
02:25We are going to actually add a photo to this flower through the File Attachments field.
02:30We are going to click Browse, and we are going to choose our pink flower.
02:36We will click Attach, and we see Drupal now has uploaded the file to this node.
02:43We are going to deselect the List option, because we don't want this file listed
02:49at the bottom of the node, and we are going to copy the path Drupal has prepared
02:53for us that points to this image file.
02:57The reason why is because we are going to take this copied path and actually
03:01paste it into an image tag that we are going to now type into the Body area
03:09of our flower node.
03:10So I am going to paste the path to the image, and this will be used for the Star Gazer flower.
03:18Since we have added an image tag, which is HTML code, into the Body area, we need
03:23to make sure Drupal is actually going to render this tag.
03:26By doing so, we need to make sure the Input formats are set up correctly.
03:32Filtered HTML is a very good, safe Input format that will actually make sure
03:36that there is no malicious code inputted in the Body area.
03:40Full HTML is the same as Filtered, but with some additional tags that it allows,
03:46specifically, for us, the image tag.
03:49So we need to make sure Full HTML is set, our image tag and text is placed in the Body.
03:57We want to give a custom URL for this, so we will say flower/star-gazer.
04:03The last options to check are that our flower will be Published and Promoted to the front page.
04:09This is what we want.
04:10Just click Save, and we see that we now have our first flower node. It has an image.
04:17And just to let you know, this image was already pre-sized before I uploaded it.
04:23So Drupal will now automatically resize it for you.
04:26So this looks good.
04:27We have one more flower we need to add.
04:30So we will click Create content again, and then click Flower, and we will call
04:34this one Sunflowers.
04:36We also have text for this node, so I am going to highlight, Copy, then Paste
04:44that text right into the Body.
04:46Then we go down to File Attachments, we are going to add an image.
04:50Here is the sunflowers image, click Attach.
04:54We see Drupal uploaded it correctly.
04:56We are going to delist the site file.
04:59We are going to then Copy the path to this image file, which Drupal provides.
05:05So Copy, and now we will Paste that URL inside an image tag within our Body.
05:13So I am going to Paste the path to that image.
05:19We see that we have now an image tag in our body.
05:21So our Input format needs to reflect that change.
05:25So Full HTML is chosen.
05:27A URL path will be set, so flower/yellow will be the path.
05:35And we are going to make sure that our Publishing options are set to both
05:38Published and Promoted to front page. Looks good.
05:42Let's click Save.
05:43And now we have a second flower at its custom URL, with an image.
05:49Everything looks good.
05:50So just so you know, in the Chapter 02 Exercise folder, there is an additional
05:54flower photo and text, if you wanted to add a third flower to the Drupal site.
05:59So now I have shown you how to create a custom content type called flower and
06:04how to add a couple of flowers to the site.
06:07You should be comfortable now with content types and custom node types.
06:12These custom content types will come into play later when we are starting to
06:15define custom templates for our theme.
Collapse this transcript
Adding RSS secondary content
00:01Now that Drupal is set up with our main content, known as Nodes, we can add some
00:05secondary content to our flower shop site.
00:08For this site, we will be subscribing to an external RSS news feed, which will
00:13show up in a sidebar next to our main content.
00:16If you're unfamiliar with RSS, it's a new technology that allows you to
00:20subscribe to a website's content without having to visit that page.
00:25So, starting from our Administer screen, we can actually go to the Feed
00:29aggregator administration page.
00:31So on Administer, find the link, Feed aggregator.
00:35If you do not see the Feed aggregator link, that's because the aggregator module
00:39has not been enabled yet on your site.
00:42You need to do that before we can add an RSS feed.
00:45So, clicking on Feed aggregator, we are now brought to the Feed aggregator page,
00:50where we see that there are no feeds added to our site, currently.
00:54So, we are going to go up into the tab area and click Add feed.
00:59And we see to add a feed, we need to supply both a title and a URL for the RSS feed.
01:05For this site, we are going to add the Drupal News RSS feed.
01:09And we are going to get that, actually, from the official Drupal webpage.
01:14So, this is the official Drupal homepage, drupal.org, and at the bottom of this
01:18site is actually a little icon known as an RSS icon.
01:23We can right-click and copy the link pointing to this RSS icon and we can come
01:30back and actually paste into the URL and click Save.
01:36If you're unfamiliar, again, with RSS, you will actually start to notice that
01:40little RSS icon appears on many other sites.
01:44And as you see, at the bottom of the New York Times website, for example, they
01:48also carry RSS feeds and they use the same icon.
01:52So, you should be able to subscribe to your favorite sites through their RSS feeds.
01:57Okay, going back, we now can close these extra tabs and going back to our Drupal
02:04we see that the feed Drupal News was successfully added.
02:08So, let's check that.
02:09We click on List in the Feed aggregator screen and we see Drupal News
02:14actually comes up listed.
02:16But we notice that there are zero items here.
02:18That's because the feed was never updated.
02:21Now Drupal can auto update these feeds on its own, but we need to tell Drupal to
02:27update right now, because we would like to see this content.
02:31So, instead of waiting for Drupal, we clicked update items and now we see that
02:35there are 25 items listed in this feed.
02:37Well, how can we be sure of that?
02:39We can click the feed title from the screen.
02:41I am going to open it in a new tab,
02:44wisit the Feed aggregator screen, and now we see that there is content that we do
02:48not add by hand to our site.
02:52This is all the RSS content coming in from the Drupal News feed.
02:57So, I am going to close this screen and go back to the Feed aggregator screen.
03:01So, not all Drupal sites will need or use RSS feeds and as we will see it later,
03:06these feed items will get themed just like the rest of the site content.
Collapse this transcript
Finalizing site navigation
00:00With our Drupal site setup with blog and page content, we can now lock down
00:04our site navigation.
00:06We'll need to administer the Primary menu to add and rearrange a couple of links
00:11that don't appear there now.
00:13The Primary menu is actually displayed right now in the top right corner of this
00:17default Drupal theme.
00:19To administer that menu, we need to go to the Administer screen and then Menus.
00:25In here, we are going to effect the Primary links menu and we see the about
00:31us and services links appear there now, just as they do in the menu of the top right.
00:37These links were actually entered into the menu automatically when we were
00:41adding the page content.
00:43We are missing two links that need to appear here.
00:47One is for the homepage and one is for the blogs.
00:50Even though we didn't create a homepage, Drupal automatically adds a homepage,
00:55which lists all the front page content.
00:58So, we can actually just point right to that front page and get a link added to our menu.
01:03I am going to click Add item.
01:06And the Path is going to be different for the homepage than every other link
01:09you are going to add in Drupal.
01:11For the homepage we can use <front>.
01:16This is a keyword for Drupal that it understands to point to the homepage, no
01:21matter what content that is.
01:23For this menu, we are going to say 'home' and we are going to click Save.
01:26You see that the Home link has been added.
01:28We are going to add the final link, which is blog and the path is actually going
01:33to be blog itself along with the menu title.
01:37If you were to add a path that was incorrect, Drupal will let you know.
01:41I am going to click Save and now we see that our four menu items are all listed
01:47as expected, but they are not in the right order.
01:49To fix this, Drupal allow us to drag-and-drop any menu item.
01:52So, we are going to have home at the front, blog at the end, services up here
01:58before about us, click Save configuration and now the menu has been updated.
02:03We see in the top right corner that that menu is totally updated, even for the top header.
02:10So, now that our content is loaded and arranged in Drupal, we can move on to
02:14learning how to theme all of this content.
Collapse this transcript
3. Essential Tools and Modules For Theme Creation
Installing the Theme Developer module (aka Devel)
00:01One of the best tools for Drupal building is actually a Drupal module, known as the Devel.
00:05The Devel module is actually a suite of modules, or tools for developers
00:10and theme builders.
00:12The tool within this suite we plan to use for theme building is known as the
00:16Theme developer module, which helps themers target any element on a Drupal page.
00:22In this video, I will introduce the Devel module suite and the Theme developer
00:26module, which will be used at certain points throughout this course.
00:31So, since the Devel module suite is something that doesn't come with Drupal, we
00:35need to go download it from the Drupal website, Drupal.org.
00:39So, I've visited the Devel page in another tab. The URL is
00:43drupal.org/project/devel.
00:48Again, this is a suite of modules, so you only have one download and the
00:53downloads are at the bottom of the Project page.
00:58You will want to download the Recommended version for your Drupal installation.
01:03So since I'm running Drupal 6, I'll be downloading and using only the Drupal 6
01:07version of the Devel module.
01:09So, go ahead and download this module and Unzip the file, so we can actually
01:15install this suite into our Drupal site.
01:18So, I've downloaded the Devel module and actually saved it on my Desktop.
01:22This Devel folder needs to go into my Drupal sites all modules folder. This is
01:29where I install new modules for Drupal.
01:32So, I'm going to open my Drupal folder and as we see, this is a standard Drupal 6
01:37site, so there's sites folder, we go in there and then we will actually visit
01:41the all folder and we see that there is nothing in here for us to place our new
01:46contributor module in.
01:48So, we'll create a New folder called 'modules' and inside there, we'll actually
01:55just drop in the devel module.
01:58Remember, you'll only want to install new modules within the sites/all/modules
02:04folder, not within Drupal 6 itself.
02:08So, now that this module folder has been added, we can go back to our drupal
02:12site, visit the modules administration page, so we're going to click modules
02:18from administer, we're going to scroll down and we're going to look for the
02:22Development modules.
02:24Remember, the Devel module is actually a suite of modules.
02:28That's why you'll see these five modules listed after putting in the Devel folder.
02:33We are only going to use the Theme developer module, but it does require that
02:38the standard Devel module is enabled.
02:41So, once those are both checked, we can click OK.
02:44And we'll save the configuration, which has now enabled our Development modules.
02:50We see a success screen and a new little floating Themer info window appearing
02:57in the bottom left corner.
02:59We're going to come back to this in a second.
03:01So, right now, I would actually want to visit the Home page of our site built as
03:06it is now, before I enable the Themer Info window. The reason why is once this
03:11is enabled, I can no longer click around the site and browse.
03:16The Themer Info window is actually going to override every click that we do on
03:21the page and provide us some contextual info.
03:24Let's see that now.
03:25So, we click to enable the Themer Info window and we see now that there is this
03:30floating panel that can be moved anywhere on the screen and if we move our mouse
03:35away from that floating panel, we see now that we start to get some live
03:39contextual highlighting of basically any element our mouse is over. These red
03:46contextual highlighted boxes are provided by the Theme developer module.
03:51This is very similar to a plug-in for Firefox that web developers use, known as Firebug.
03:58So, we can actually now click any element, even the link and get some
04:03updated information.
04:05So, let's click the body.
04:07Let's try the whole flower.
04:09Let's try just the links and we see that all that information in the pop-up gets changed.
04:16So, what we want to do is actually choosing element to target and this panel is
04:21going to let us know what we're going to be targeting within our Theme files.
04:26So, we can see that there are some functions called, some elements that are
04:30involved with the data.
04:33We won't dive too deeply into this panel for this video, since we'll be using
04:37this plug-in throughout the entire process of building our theme.
04:42So, since the Theme developer module actually obstructs us from browsing our
04:47own drupal site, since it's on, we need to make sure we disable it, when we're not using it.
04:52So, we actually will go down to the bottom left corner, where it says Themer
04:56info, and make sure that the checkbox is unchecked and we see now that we no
05:02longer get the contextual red highlighting and we no longer have the floating dialog panel.
05:08Even though we have disabled the Theme developer panel, we have not actually
05:13disabled the entire module.
05:16Tools like the Devel module and its Themer Development module should never be
05:20left enabled on any public facing website, because these modules use a lot of
05:26computer memory, or RAM and can result in negative performances.
05:30So, let's go back to the modules administration screen.
05:33That's under in Administer > Modules and let's disable the Theme developer
05:40module and we cannot disable the parent Devel module until Theme developer has
05:47been fully disabled.
05:49So, we will click Save configuration with Theme developer unchecked.
05:54We'll go back down and make sure that Devel itself is also now unchecked, since
06:01we can disable that.
06:04After clicking Save configuration, we just double check that those modules are
06:08disabled and they are.
06:10We can now continue building our drupal website.
06:14Tools like the Devel module are great for development but should never be left
06:18enabled on any public facing site, since modules like these use up a lot of RAM,
06:23or computer memory and can result in negative performances of your website.
Collapse this transcript
Ensuring cross-browser compatibility with conditional style sheets
00:01There are bound to be moments where browsers will render your site differently.
00:04The most common culprit is Microsoft's Internet Explorer, or IE as it's
00:09more commonly known.
00:11Internet Explorer has a history of inconsistencies with each version released
00:15and in this video, I'll show you how Drupal themers are able to package what is
00:20known as a conditional style sheet, allowing our theme to deliver styles for IE
00:26directly, on any version.
00:28So, to pull off the conditional style sheets, two things have to happen here.
00:33One, we need to install a module actually called conditional style sheets, this
00:38is a free module available on Drupal.org.
00:41This module utilizes conditional style sheets that have been created by
00:46Microsoft and you can view this Microsoft page to learn more about them and even
00:51find out more about the syntax that we are going to be using in this video.
00:55So, go ahead and download the Drupal 6 version of the Conditional
00:58Stylesheets module.
01:00I have done so already and we need to install this module into our
01:05sites/all/modules folder, and if you do not have this modules folder inside your
01:10sites' all folder, you should create it now.
01:14All extra modules that don't come with Drupal, will go inside this module.
01:18So I just dragged my conditional_styles module into the folder and now I'm going
01:22to minimize my Drupal folder, so that I can go back to my browser and actually
01:27activate this module.
01:28So, we're going to go to the Modules administration page, scroll down, find
01:35the Conditional Stylesheets module, click Enabled and then Save Configuration to
01:40activate the module.
01:41Good, the module is ready for us.
01:44There is nothing to configure within Drupal itself for this module, instead we
01:50need to make a change to a theme.info file that we'll be actually learning more
01:55about in the next chapters.
01:57There's nothing to actually configure within the Drupal administration interface
02:01for this module, instead we need to edit our theme manifest file or our
02:06theme.info file to take advantage of this module's features.
02:10So, let's actually go and open our Exercise Files folder and in Chapter 3, there
02:16is a folder there called Condition.
02:18The Condition folder is actually a Drupal 6 theme that we can install in our
02:23Drupal site to see the conditional style sheets feature being used.
02:27So, I'm going to actually copy the Condition folder and actually paste that
02:33folder into my sites/all/themes folder.
02:39If you do not have a themes folder in your sites' all folder, go ahead and create it now.
02:44So, pasting the condition theme inside my sites' all themes folder, we should be ready to go.
02:51Go inside the condition folder and open the condition.info file.
02:57In here, I've actually prepared two style declarations that will go with this theme.
03:03The first is called not-ie.CSS and this will be loaded by every browser.
03:09The second line, line 11, is actually a conditional style sheet line that says
03:16if the browser is IE 7 then go ahead and load the for-ie.CSS file.
03:25Since, I want to make sure that this IE file is loaded for all Internet Explorer
03:29versions, I'm going to remove the 7 and I'm going to click Save.
03:32So, I'm going to go back to my Drupal administration screen and go into the
03:36themes administration page, so I can enable this new Condition theme.
03:41So, we enable the theme by clicking enabled and actually choosing it as our default.
03:47Now, we'll click Save Configuration and then we'll go to the Homepage of our
03:52site and we see that this is not really a pretty theme, but we're here just to
03:57show you conditional style sheets will be loaded.
04:00So, let me edit this page and click View Source.
04:04Now, we see the style sheets loaded for this condition theme, not-ie.CSS and
04:10we see the other code needed for the conditional style sheets, automatically added by Drupal.
04:16We see this code and it states that if the browser is Internet Explorer,
04:21any version, go ahead and load this additional style sheet called condition for-ie.CSS.
04:30Now what I'm going to do is I'm going to disable the Conditional Stylesheets
04:33module, so you can see what's going to disappear when that module is not active.
04:39We will go back to the Modules administration, I'll disable the Conditional
04:43Stylesheets module. Once this is done, we'll go back to our Homepage, click
04:48Refresh and now we'll actually view the source again and we see that only the
04:54not-ie.CSS file is now showing.
04:57For the rest of this course, I'm going to actually keep the Conditional
05:00Stylesheets module enabled, just in case we need to create some IE-only styles.
05:07Using the Conditional Stylesheets module is a proper method to adding any
05:11Conditional Stylesheet without having to do additional programming.
Collapse this transcript
Using Firefox extensions for site development
00:00Throughout this course, I will be using the web browser known as Firefox to
00:04preview our Drupal site for two reasons.
00:06One, Firefox is reliable when viewing web pages that use CSS and two, there are
00:12plug-ins available, known as extensions, that enhance the browser, providing tools
00:17and features that only a web designer could love.
00:20In this video, I will show you a couple of Firefox extensions I use for
00:24Drupal theme development.
00:25So, since these extensions are for Firefox and not Drupal directly, we have to
00:31actually make sure Firefox is installed.
00:34So, I already have Firefox 3 running, and I want to show you the extensions I
00:39use for Drupal theme development.
00:41So the first Firefox extension I would like to introduce to you is known as the
00:45Web Developer Toolbar.
00:47This is free for Firefox and I've already installed it, so I'm going to enable
00:52this toolbar by right-clicking in Firefox and selecting Web Developer Toolbar.
01:00We see, now, that I have a whole new toolbar for Firefox.
01:04This toolbar is very powerful and provides features that work for CSS,
01:09JavaScript, Cookies and many other things that Drupal uses.
01:14One of the best features is actually to outline the block level elements of a
01:19page, letting me see the page structure or its blueprint, as some people like to call it.
01:24So I'm going to disable this now by unselecting Outline Block Level Elements,
01:30and introduce the second popular extension for Firefox that I use, known as Firebug.
01:37Firebug is also free and is very powerful for CSS and JavaScript developers.
01:42I already have Firebug installed and I can actually enable Firebug in the
01:47bottom toolbar of Firefox by clicking on the Firebug icon, and I can click again to close it.
01:55Or I can right-click any element in the page and say Inspect, which will then
02:01bring up the Firebug dialog.
02:03In the Firebug dialog, I can actually see areas of a page get highlighted, as
02:09with the blue box hovering over content, where my mouse is hovering within the page markup.
02:16I can click on any element. Any element on the page can be highlighted with Firebug.
02:22In addition to highlighting where that element is, we can also modify that element.
02:28So when I've clicked on the div and it has an id of content, we can see in
02:32the right pane of Firebug that there are some associated Styles for this HTML element.
02:39We can see the background image, we could see all the padding, we can see its
02:44size and we can even affect these values and see them change live right on any page.
02:50So, if I were to disable the styles, we would start to see the page change.
02:57Now, we could re-enable the styles and see the page change back.
03:03We can also change to these values, like I was saying before, so let's try
03:08changing the left dimension to say 400 pixels and now we see that the element on
03:16the page has actually moved 400 pixels to the right.
03:20We can then change this back.
03:23So, when developing Drupal themes, you can definitely see with Firebug what
03:27elements might need to be moved and try them out before you're editing any
03:31of your theme files.
03:33Firebug is a great tool to use when developing any type of website.
03:37So last, I have a Firebug add- on called Drupal For Firebug.
03:43So this requires that Firefox is installed with Firebug and this is an add-on
03:48for Firebug, specifically for Drupal.
03:51So, there is actually this add-on that you put into Firebug and an associated
03:55module for Drupal called Drupal For Firebug that are both used together to
04:00provide you some really nice information that appears in the Firebug panel, but
04:05specifically for your Drupal site.
04:08So, I'm going to actually show you how to enable and install this Drupal For Firebug plug-in.
04:13The first piece that we need to actually install is the Drupal for
04:16Firebug add-on for Firebug.
04:19So, we make sure that that's installed.
04:21And I've already installed that on my machine.
04:23The second piece is the module for Drupal, known as Drupal For Firebug, which we
04:29need to download and install ourselves.
04:31So, I've already downloaded the version 6 module.
04:34The first step when, of course, installing any Drupal module is to put the module
04:38folder inside your sites/all/modules folder.
04:42So, let's go and do that.
04:43So, I'm going to minimize my browser and we see that I have the
04:46Drupalforfirebug folder ready.
04:48I'm going to open my Drupal-6 installation and visit the sites/all/modules
04:54folder and again, if you don't have this folder here, you need to create
04:58this module folder.
05:00So, go inside modules and just the same as the devel in our other video, we
05:04bring in the Drupalforfirebug module.
05:07Remember, that's in the sites/all/modules folder.
05:11So, now that we've actually placed the module inside our Drupal site, we need to
05:16enable the module within Drupal.
05:18So I've opened my web browser and I'm going to go back to my Drupal site.
05:23On the Administer screen, we're going to go through and administer the modules.
05:27So, click Modules and down at the bottom, we should see a new section of modules,
05:33known as Drupal for Firebug.
05:36So we're going to actually enable both of the modules that come with that
05:40Drupal for Firebug suite.
05:41And we're going to click Save configuration.
05:45Now that the Drupal for Firebug modules are enabled, we can use these
05:49throughout our site and they actually activate very simply, because they are
05:53built into Firebug.
05:54So, let's visit the Homepage, let's open our Firebug console and now let's visit
06:00the Drupal tab within Firebug.
06:03We see that this homepage has some nodes, so we can use the Nodes secondary tab
06:10and the Drupal For Firebug plug-in to actually see what nodes are loaded and
06:15how they were loaded.
06:16So, we see that we actually get some information that we can inspect.
06:21This is the actual node object, this is the node data that Drupal sees,
06:26before it is themed.
06:28So, we see that every module on the screen, on this page, is actually getting
06:32inspected now by the Drupal For Firebug plug-in.
06:36So, since Firebug and Firefox will be used throughout this title, it is highly
06:41recommended that you install them both.
06:43You don't need to have the Web Developer Toolbar or this Drupal For Firebug
06:47add-on to follow along in our title.
06:50If you already have Firefox, make sure it's an up-to-date version and the same
06:54for Firebug, if that's already installed on your machine.
Collapse this transcript
Working with Dreamweaver
00:01Many designers use Dreamweaver as their primary Web Editor.
00:04By default, Dreamweaver cannot render Drupal theme files with their style sheets.
00:09In this video, I will show you how to set up Dreamweaver to work better
00:12with Drupal themes.
00:14So I'll be using Dreamweaver throughout this course and I already have it open.
00:20So this version of Dreamweaver is CS4 and what I'm going to show you is a nice
00:25little feature that is available in many versions of Dreamweaver, not just CS4.
00:29What we're going to do is, essentially, binds or link style sheets to Drupal
00:34templates and, by default, Dreamweaver cannot do this on its own.
00:38It needs a little help from you, the user.
00:40So I'll be opening up a theme template file and we will be covering theme
00:45template files throughout the rest of this course.
00:47So what I'm going to do is actually grab one of the default themes, bluemarine,
00:53and I'm going to open the page.tpl.php file.
00:58Now, normally, this is what everyone sees in Dreamweaver when they're in Code view,
01:03and this is what everybody normally sees in Dreamweaver's Design view, when
01:07editing a Drupal theme template.
01:10Not really much to see here, but there are style sheets with every theme, so
01:15let's get these actually linked together.
01:17So what we're going to do here is actually go over to the CSS Styles panel,
01:22and in the Contextual menu on the right side, we're going to click and choose Design-Time.
01:28This now brings up a dialog window that allows us to apply what's known as the
01:33Design-Time Style Sheets.
01:35This is a feature only for Dreamweaver and is a very good feature for when
01:39working with Drupal themes.
01:41So Dreamweaver can actually have as many style sheets as you want applied to a
01:46template, but only rendered for Design view.
01:50So let's go ahead and click Plus and in the bluemarine folder, we'll actually
01:55choose the style sheet used for the theme.
01:58So that's style.css, we click OK.
02:03We see style.css is now associated as a Design-Time style sheet.
02:07That's what we want, click OK.
02:09And now we see a difference in the plain white that we're used to with standard
02:14Drupal theme templates.
02:16In fact, if you go and look on the CSS Styles panel, we now see every style
02:22declared for that theme.
02:24We can edit it as normal, just like Dreamweaver people would expect, okay.
02:31And we can now also look at the elements on the page and even change their ID's
02:38or Classes or maybe even apply your own.
02:41A very important note about this Design- Time Style Sheets feature in Dreamweaver
02:45is that it will not add any markup or code to your Drupal templates.
02:51Dreamweaver itself will remember, in the background, what templates are linked at
02:56design time to what style sheets.
02:58This is a very good feature since there should be no style sheet markup in any
03:04of the templates whatsoever.
03:05While not every designer uses Dreamweaver,
03:09it is a powerful tool on its own for editing web pages.
03:12When working with Drupal, Design-Time Style Sheets is a hidden feature that
03:16helps bridge the gap between Drupal themes and Dreamweaver.
Collapse this transcript
4. Theme Administration
Choosing a default theme
00:01Drupal sites can have more than one theme installed.
00:03When a Drupal site has more than one theme enabled, we must choose one theme to be the default.
00:09This video shows how to enable multiple themes and change the default theme
00:14for our Drupal site.
00:15So I am going to go start from the Administer screen in Drupal.
00:18I am going to click on Themes, and this is going to bring me to the Theme
00:22Administration page.
00:24This is where all the themes that are installed in your Drupal site will be listed.
00:28In fact, we see that there are six themes, by default, that come with Drupal 6.
00:33The standard default theme is known as Garland, and we see that Garland is both
00:38enabled and set as the default theme.
00:41As you can notice from this quick, small form that the Enabled column is filled
00:47with checkboxes allowing us to select multiple themes to be enabled.
00:51But the Default column has radio buttons, only allowing one theme to be the
00:56default at any given time.
00:59Some of things to point out here. You need to make sure you click Save
01:02configuration after choosing a new enabled and default theme.
01:06So let's see that right now.
01:08I am going to change the theme to be Bluemarine, so I am going to Enabled the
01:12theme and change the Default.
01:14I am going to go leave Garland checked.
01:16I am going to come down and click Save configuration.
01:19We have now changed the default theme, as you can see, to Bluemarine.
01:24So let's visit our homepage to see how it looks.
01:26It looks different.
01:28Let's go back to Administer, let's go to Themes, and now let's go back to
01:36Garland by leaving both themes enabled, yet choosing Garland to be the default.
01:42We are going to click Save configuration again, and now the default theme has
01:46been changed to Garland.
01:48You can enable as many themes as you like in Drupal, but only one theme to be the
01:53default that visitors see.
01:55This administration screen is going to be an important page throughout our course.
01:59We will be coming back to the screen when installing, or configuring any
02:03new themes.
Collapse this transcript
Touring the core themes
00:01After learning how to change the default theme in Drupal, it would be good to
00:05go through all of the default themes that come with Drupal 6, otherwise known
00:08as the Core Themes.
00:10So to get to the themes, we need to start from the Administration page.
00:14So Administer>Themes and we see we have the default six themes that come
00:21with Drupal 6, and I am going to go through and actually enable each one of these themes.
00:27I am going to go click Save configuration, so they save that to be Enabled,
00:32and now I am going to go actually start switching the themes,
00:35so we could see each one in action.
00:37So, the first one is Bluemarine.
00:39So, I chose the Default radio button and click Save configuration, and now we see
00:45that Bluemarine has been taken over as the default site theme.
00:48So I am going to go open a new tab to visit the homepage, so we can come back to
00:54this theme administration screen easily.
00:57So I click on my new tab and this is the homepage, and if I visit the other
01:01pages, we can kind of see how this site looks.
01:05Now remember, the View and Edit tabs only show for people who are logged in, and
01:09have permission to edit a note.
01:11So these will go away for normal users.
01:13Let's see. Anything in the blogs?
01:17Okay, it looks like blogs.
01:19Let's go back now, and actually switch the theme to Chameleon, and click
01:26Save configuration.
01:27Now we have this kind of nice all white theme.
01:32We see that some of the stuff had changed, like the positioning of the primary menu.
01:36We also see that there is now a logo appearing.
01:40We want to check out the other pages real quick, so let's visit them in a new tab.
01:44So here we see, actually, the Services page node, loading in the Chameleon theme.
01:50Here is the about us, here is the blog, looks pretty good.
01:53We've a couple other themes.
01:56We'll switch over to, now, Marvin, click Save configuration.
02:01We will go over and open a new tab.
02:04We see, already ,this is quite different.
02:06In fact, it's actually a liquid-based layout.
02:08The Chameleon theme looked like it was a fixed-width layout.
02:11We will see that difference between multiple themes in this video.
02:16We noticed that there are some differences, like the headers have a box around them.
02:19It looks quite different.
02:23So let's close this and let's actually look at the Minnelli theme, which looks
02:28just like Garland in the previous screen shot.
02:30So let's see what that's about.
02:32So I enabled Minnelli as the default, and it looks just like Garland, but with
02:37one apparent difference.
02:38Go to the Home. We see, now, that, actually, this is a fixed-width version of Garland.
02:44Okay, so let's look at the other pages real fast, looks good, looks good. Okay.
02:50Close, and we have one final theme to go through here, which is Pushbutton.
02:54Let's click OK, Save configuration, and we see this is also a
03:00liquid-based layout.
03:02So let's go and view the homepage, and see how our content looks.
03:05It looks pretty good. Click services.
03:09It looks fine, About us, blog.
03:11It's got some orange and some blue.
03:16Well we've gone through all the themes, but Garland is probably the most
03:20reliable out of all the default themes.
03:24You can pretty much expect Minnelli as just as reliable, because, technically,
03:27Minnelli is what's known as a sub-theme, or a theme based on a parent theme, and
03:34its parent theme is actually Garland.
03:36One important difference that Garland and Minnelli have over all the other
03:41themes is that these are the only two default themes in Drupal 6 that do not use
03:47HTML tables for their layout.
03:50In fact, these are tableless and all the other themes are tabled.
03:55One big difference, too, is this theme Chameleon is actually a pure PHP-based theme.
04:05So there are no templates that power Chameleon.
04:09So programmers actually can reference Chameleon to see how they can code a
04:13theme with just purely PHP, but that's not what we are doing in our title, we
04:19are actually be going through and building themes with templates.
04:23And we are not going to be basing any of our templates off any of these themes
04:28that do provide templates, and before we are done here, I don't plan to leave all
04:33of these themes enabled, I only want Garland enabled.
04:36So let's actually deselect each of the other themes, from being Enabled.
04:42I do not recommend deleting any of the Core Drupal themes, but if you're going
04:46to take things into your own hands and choose to delete some of the default
04:50themes then be sure to never ever delete Garland or Minnelli, as these themes
04:56power both Drupal's installation and update screens.
05:00You're asking for trouble when deleting anything in Drupal's Core.
05:05Even though some of these themes look great, they aren't the best way to learn
05:09how to build a Drupal theme, unfortunately.
05:11Figure, these themes are all legacy and should be treated as such.
05:15Throughout the rest of this course, we will be building a sub-theme built on top
05:19of Garland, and a custom theme not built on any of these themes at all.
Collapse this transcript
Configuring global theme features and post settings
00:01In Drupal, themes have features.
00:03These theme features allow designers to toggle elements a theme can control,
00:07like if the site logo is shown or not.
00:10In addition to features, Drupal themes share global display settings that allow
00:15you to set which node types would have author info appearing in them, which is
00:20perfect for blog posts, but not pages or our flower products.
00:24Let's see what features and post settings are available in Drupal 6, and how
00:28they affect all themes.
00:30So to configure the global theme settings for our Drupal site, we need to visit
00:34the Themes Administration page.
00:36So from the Administer screen, we click Themes and there is actually a tab up
00:42here at the top that says Configure.
00:45Now this Configure link is different from the configure links that appear next
00:50to each theme that is only enabled.
00:51We are not going to go here. We are going to, actually, click up in this tab, next
00:56to List, and this brings us to the Global Settings page for themes.
01:02Now this page will actually affect all themes across our site.
01:06Right now we only have Garland, but we can still set these settings now, and
01:11have our custom themes pick up these settings later.
01:15So the first side that I'll introduce to you is the Toggle display side, these
01:19are the theme features I was mentioning, and we can do things like toggle off
01:26the Logo, toggle off even things like Primary links.
01:30The Primary links, remember, are our main menu navigation up at top, and the logo
01:35appears in the top left corner of Garland.
01:38So with the Logo now off and the Primary links also off,
01:41let's click Save configuration, and see what happens.
01:45Now we see that Drupal has respected our feature settings, and has removed the
01:50logo and the primary menu.
01:53Let's bring those back, Logo and Primary links, Save configuration and now they are back.
02:01There is one feature, before we leave this box, that I want to make sure is
02:04enabled, and that's the Search box.
02:08We are going to use this in our custom theme later on.
02:11So make sure it's enabled.
02:14Now coming to the right side of this administration screen, we see the Display
02:17post information, and in here is actually a list of every content type, or node
02:24type that is actually installed into our site.
02:27So we see that default Drupal content types: Blog, Page and Story and any of our
02:33custom types, which, right now, we have as Flower.
02:36This Display post information, as it outlines in this help text, is actually
02:40where you can deactivate, or remove the author name, and info details of the
02:47post, when they are viewed.
02:49So let's actually make sure that Pages do not have the author info, nor our flowers.
02:56So I am going to go to, actually, before I click Save configuration, I am going to
03:00go open the Homepage in the new tab. So we can see right now, we actually get
03:05the author details at the top of every Flower post, and of course, as expected, at
03:13the top of every blog post.
03:15We do not want this on the flowers, but we do want this on the blogs.
03:21So let's go back to the Themes Administration screen, make sure we are in Global
03:25settings, and we are going to uncheck Flower and Page and click Save.
03:33So now that our configuration options have been saved, let's go refresh
03:36our Homepage tab and see how the flowers will now no longer carry the author details.
03:43Click refresh and now Drupal has removed the author info from the flower types,
03:50but, as expected, not from our blog types.
03:53We can even check our services page, and see that it no longer also has the
03:58author info, nor the about us page, and that's what we want.
04:02So closing this tab, going back, we can now see that any content type that we
04:07create, or is added by a module that we install, would actually appear here, and
04:12we should come back to this screen anytime we've created a content type or
04:16install the module that provides a new type to make sure that we set which ones
04:21would actually have posts information and which one should not.
04:24These standard features available to all Drupal 6 Themes are good enough for most users.
04:30Theme features are neat but are limited to the defaults that you see here in Drupal.
04:35If you're wondering if a custom theme can have its own custom features, this is
04:39possible, but it requires a lot of complex PHP programming, and should be left
04:44in the realm of developers.
Collapse this transcript
Adding a logo and shortcut icon (favicon)
00:01One of the simplest ways to customize a Drupal site through its theme layer is
00:05to change the logos.
00:07In this video, I will be showing how to change both the logo and the favicon
00:11that usually appears at the top of a web browser.
00:14So to change the logo and favicon in Drupal, we need to visit the Global
00:19settings screen, under the Theme Administration page.
00:22To do that, we will start from the Administer screen and click on Themes.
00:26Now that we are at the Themes administration screen, we will click on the tab
00:31Configure to reach the Global settings page.
00:35In here is where we can actually add the logo and favicon.
00:38If you are unfamiliar with what a favicon is, they are also known as shortcut
00:43icons and they appear at the very top, usually, of your browser, next to the
00:48address of the site you are viewing.
00:50We see there is a small Drupal logo used on the site, but an even smaller
00:55version of the logo used as the favicon.
00:57We are going to replace both of these graphics.
01:01So let's go down to the bottom of the Global settings page, and we see these two
01:06areas that allow us to upload a graphic file for the logo and down here, a
01:11little form that allows us to upload a favicon.
01:14For this demonstration, I am going to be using the same graphic file for both
01:18the logo and the shortcut icon.
01:20So to change a logo, let's click Browse, and we are going to pull in the
01:25hp_logo graphic file you see here, which is actually a logo for the Hansel and
01:33Petal Flower website theme that we are going to be building throughout the rest of this course.
01:38So this is where this file comes from.
01:40So we are going to click OK and then for the shortcut icon, we are going to
01:44click Browse as well, and choose the same graphic, click OK.
01:49Now, when we click Save Configuration, you are going to notice that the logo and
01:54the favicon have both been changed.
01:56So if you look in the top-left corner, we see that the logo is now the custom
02:00logo graphic we uploaded, and if you look real closely, the favicon has changed as well.
02:08A favicon should be designed at either 16X16 pixels, or 32X32.
02:15As you can tell, this graphic is nowhere formatted to be that size, so it
02:21doesn't look good as a favicon.
02:22I am sure when you do your own custom logos, you can create a good one for the
02:28browser's favicon tab.
02:30So after uploading these, where does Drupal save these files?
02:33Well, let me show you.
02:35So I am going to open my Drupal folder.
02:37I am going to go into the sites folder, and then my lynda-drupal-themes folder,
02:42which is this Drupal site we are building, and in there, there is a files folder
02:47where all the files have been uploaded for our content.
02:51In here, we can see that there are two new files, logo and favicon.
02:58These files are actually the ones we just uploaded.
03:01Drupal had renamed them to be logo.png and favicon.png.
03:07This is where Drupal is now calling these graphic files for our theme.
03:11So I am going to minimize my Drupal folder and before I go, I want to actually
03:17revert back the logo and favicon to the standard Drupal logo.
03:22So let's scroll back down in the Global settings page, and we are going to check
03:27this box that says Use the default logo and we will check the box, also, that says
03:33Use the default shortcut icon.
03:35We will leave the values in for our custom logo and custom favicon.
03:40Those will be just fine and as long as this check box each are enabled, it will
03:45override what this path is.
03:48So let's click Save configuration and you see now both the logo and favicon
03:54have reverted back.
03:56For people who like the default theme in Drupal, changing the logo is the
04:00easiest way to customize the look of a Drupal site without adding or editing
04:05any code.
Collapse this transcript
Setting the administration theme
00:01Earlier, we learned that Drupal can have more than one theme enabled.
00:04A great use of this feature is when a site would like to have one theme for
00:08visitors, and one theme for its site administrators.
00:11In this video, I will show how to select an administration theme that only
00:15site admins will get to see, while everyone else will continue to see the
00:19default site theme.
00:21So to set the Drupal administration theme, we're going to be visiting a new
00:25screen that we have not seen yet in this course, and that's the
00:28Administration Theme page.
00:31So starting from the Administer screen, we're going to click on Administration
00:35theme, which is its own link, and when we come to this page, we see two
00:40elements that we can set.
00:41The first is our choice of which theme will be the administration theme.
00:46So for this demo, let's choose Garland, and the option to view the
00:51Administration theme while editing content. I want to use this option as well.
00:56So check the box and click Save configuration.
00:59Now, nothing has changed for us yet, because Garland is actually also our site default name.
01:07So now that we're changed the Administration theme, we can safely go choose
01:11another theme that everyone else will be able to view.
01:14To do that, we must go back to the Administer screen, so click Administer, then
01:20click Themes and now it will let you choose a new default site theme.
01:25So we're going to leave Garland enabled.
01:28So we're going to choose a theme that is different from Garland and one of the
01:31best choices for this demo will be Marvin.
01:34So we select Marvin to be enabled and to be the default theme.
01:40Remember, leave Garland checked as enabled, go down and click Save configuration.
01:46And as we see, nothing has changed, but Drupal has set a message for us saying
01:52that the Administration theme is set to Garland.
01:54So this page remains unchanged.
01:57We will need to visit the homepage to see the Marvin theme being used for our front end.
02:04Now, if we go back, and just to prove it, I refresh my Administration screen,
02:09we're still in Garland. I go back.
02:12Refresh the homepage. It's Marvin.
02:15So, let's click around and we see that Marvin is coming up for everything.
02:19But if we were to click the Administer link, we're back in Garland.
02:23So going back to the content, I want to show you now, when you edit a node, so
02:28I'm logged in and I get to see the tabs View and Edit.
02:33When I Edit this node, I'm now taken back to Garland, because I chose the
02:37option to use the Administration theme while editing content.
02:41So I'm not going to edit anything here. I am going to go back, click View and we
02:45see Marvin and this will be the last time we probably will get to use Marvin
02:51because everything we do from now on will be custom.
02:54So let's close this screen and now let's set our Garland theme back to be the
03:00default theme and let's disable Marvin, because we won't need it any more.
03:04So go down, click Save configuration.
03:08A very important note about Administration themes.
03:10Before you install any new theme, you should definitely set the Administration
03:15theme first to a Drupal core theme, like Garland.
03:19The reason being, if you install a new theme without setting an Admin theme, you
03:24could potentially lock yourself out by accident.
03:27This happens when the new theme does not have a particular feature or
03:31region expected by Drupal.
03:33By setting the Administration theme first, you avoid that scenario of getting
03:38locked out of your own website.
03:41Administration themes are not limited to the themes that come in Drupal core,
03:45and while any theme can be an Admin theme, I do recommend, strongly, that leaving
03:50Garland as the Administration theme is your best bet, since it's the most
03:55reliable theme for Administration screens.
Collapse this transcript
Installing a new theme
00:01By now, I'm sure you're familiar with the core themes in Drupal 6.
00:05I think it's time we install a new Drupal theme.
00:08In this video, I will download a reliable theme from the Internet, and install
00:12it in our Drupal site.
00:13So to do that, I actually need to download the theme first.
00:17So I am going to go visit drupal.org, the official website for Drupal, and I am
00:22going to go click on the Themes section, and now, I am presented with a bunch of themes.
00:26But I only want to filter by Drupal 06.
00:27So I am going to click to 6.x filter.
00:30And now I could see a list of only Drupal 06 themes.
00:33I am going to go scroll down, and I am actually going to download one of my new
00:37favorite themes, called Acquia Slate.
00:39This is a new dark theme developed by the TopNotchThemes group, who do
00:45excellent Drupal themes.
00:47So go ahead and click to download the Drupal 6.x version of this theme.
00:51I've already downloaded it.
00:52So let's go and learn how to install those files.
00:54I am going to minimize my web browser, and, as you could see, the acquia_slate
00:59theme folder is on my Desktop.
01:02I need to put this into my sites/all themes folder of drupal-6.
01:06So let me open my drupal-6 folder, and of course, I am going to go into the
01:11sites/all, and since we don't have the themes folder here, I am going to go create one.
01:20So remember, we are in sites/all/themes and this is actually where we would be
01:26installing any new themes for Drupal.
01:29So I am going to go drag in my acquia_ slate theme, minimize my folder and now I
01:34am going to go back to my web browser.
01:36But before I enable the new theme, we need to make sure that we have the
01:40administration theme set.
01:43So in the Administer screen, I am going to go scroll down and click
01:46Administration theme, and we see that I still have it set the Garland.
01:50That's what I want.
01:51So go back to Administer, and now let's visit the Themes page. We should now
01:56see the new theme, Acquia Slate, listed with all the other core themes that come with Drupal.
02:01We are going to enable this theme, and even set it as the default.
02:05We are going to leave Garland enabled, and click Save configuration.
02:11So now we have not seen anything changed on our side because we're still in the admin screen.
02:16So now let's click over to the home page in a new tab, and we see our site has
02:22totally changed it's theme using the Acquia Slate theme.
02:26Our primary navigation still exists, and the left sidebar renders our navigation
02:32block, just as expected.
02:34The site title is picked up, all our content is also themed.
02:38In fact, let's view one of the inner content pages.
02:42Remember, we are logged in, so that's why we get the View and Edit tabs.
02:46But we see that this is actually a very nice theme.
02:49Closing this Content page, let's visit the About Us page. It looks good.
02:54Now, let's go back to the Administer screen, and of course, we are back to the
02:59Garland theme, because the Administration screen was set to Garland.
03:04Now, before we go, even though I like the Acquia Slate theme, I am going to
03:09actually disable it because we want to create our own custom theme for this
03:14flower shop we are building.
03:16So let's go back to the themes administration screen.
03:19Let's disable Acquia Slate and choose Garland again as the default theme.
03:25Click Save configuration, double check by visiting the home page, and we
03:30are back to Garland.
03:32So even though Drupal has hundreds of themes available, I would advise you
03:36to not download and run any theme without putting it through a little bit of testing first.
03:41A good Drupal theme should render well across multiple browsers, and be
03:45regularly maintained.
Collapse this transcript
Positioning blocks in theme regions
00:01When a theme is enabled in Drupal, the secondary content, known as blocks, can be
00:05arranged differently for each theme that is enabled.
00:08In this video, I will show you the basics of setting how blocks should appear,
00:12when more than one theme is enabled on a Drupal site.
00:16So to get to the block's administration screen, we actually need to go through
00:20the Administer screen.
00:21So I am going to go click on Blocks, and now I want to show you that this is
00:26going to only configure the blocks for the default theme, which is Garland, in this case.
00:34I would rather show you how to administer the blocks when more than one theme is
00:39enabled, because basic block's administration is actually already covered in the
00:44Drupal Essential Training Course, also on lynda.com.
00:47So let's go back to the Administer screen by clicking Administer in the
00:50Navigation menu, and enabling a second theme.
00:55So let's go to the Themes administration and let's turn on Marvin, and set it
01:01as our default theme.
01:04Click Save configuration, and if you've been following along in this chapter,
01:09you will remember that our administration theme has been set to Garland.
01:14So we will only be able to see the Marvin theme, when we visit the content
01:19pages, and not any of the administration screens we are on, currently.
01:23So now that we have more than one theme enabled, we can set the blocks per theme.
01:28Let's click Administer, and now let's go back to the Blocks
01:31administration screen.
01:32We see that Drupal has actually changed to be the Marvin theme. Now, why is that?
01:38Because this is an administration screen, so shouldn't it show Garland?
01:43Well, that's not the case when administering blocks and their positions,
01:48because Drupal needs to show you where those blocks are going to appear within that theme.
01:55So on the Blocks administration screen, this is the one page, in the admin, that
02:00will actually use the default theme that is not set as the admin theme.
02:05So I want to point out, at the top, near the tabs, List and Add Block are now
02:10the list of themes that are enabled.
02:13So if we had more than two themes enabled, the other themes would also list next
02:18to Marvin and Garland.
02:20So we're making sure we are on Marvin, as we can see with the current page being
02:24rendered, and the secondary tab being chosen as Marvin.
02:28We can now go down and actually position the blocks in whichever region we would like.
02:35Unfortunately, Marvin is a pretty limiting theme, since it only has a Left and
02:40Right Sidebar, but this will work for our demo.
02:43Let's add the Drupal News feed latest items block to the right sidebar, and we
02:49did that by dragging the block into the region name.
02:54Let's also add the search form. But this time, instead of dragging the block,
02:59I am going just choose the region through the drop-down menu, next to the block name.
03:04I am going to go add the Who's online block, by dragging it in.
03:10And now we have got a few blocks that will appear on the left side and a few
03:13blocks that appear on the right side for the Marvin theme.
03:17Let's click Save blocks, and now we see the new blocks have appeared in the
03:21right sidebar for the Marvin theme, as expected.
03:25When we go to click on Garland, now, we see that the Right sidebar does not have
03:32any of the blocks that we applied towards the Marvin theme.
03:36Rightfully so, because each theme would have its own regions, and can have its
03:41own block placement in those regions.
03:44So for fun, let's add a couple regions to the Right sidebar of Garland.
03:49So I am going to add the Syndicate block, the Who's new and then the Who's online.
03:56So if I scroll up, we see Left sidebar has a couple blocks, right sidebar has a
04:00couple blocks, and we see that we can put some blocks in other regions, but we
04:05don't need to do that in this demo.
04:07Go down, click Save blocks and now we see that we have a few blocks showing up
04:12in the Right sidebar of Garland, and if we click back to Marvin, we saw the ones
04:17that we administered for Marvin, which are these right side blocks.
04:21Now, let's go and click around the website.
04:23So I am going to go open a new tab to the homepage, and remember, the content is
04:28being viewed in the Marvin theme.
04:30So we see our right side blocks.
04:32If we were to click Administer, this would show the administration screen, which
04:37we have configured to have some right side blocks now.
04:40Let's go back to the Blocks administration screen, and let's actually remove the
04:46right sidebar blocks we just added to Garland.
04:49So choose the none region in the dropdown menu for each block that you
04:54positioned in the right sidebar for Garland, and when we are done choosing none,
05:00we have to go down and click Save blocks.
05:03Now, we've brought Garland back to what it was, before we added those blocks.
05:07Instead of me repositioning the blocks in Marvin, I am going just now disable
05:13the Marvin theme, because we don't need it anymore.
05:16So we go back to Themes, disable Marvin, reset Garland as the default, click
05:24Save configuration and now we are back to where we started.
05:29Since I want to have Marvin disabled, because I don't need it for the rest of
05:33this course, it's good to know that if you were to come back and re-enable
05:38Marvin, that Drupal will remember what blocks you positioned, where, for Marvin.
05:44This is a nice feature of Drupal, as it does not forget where the blocks were.
05:48We will be revisiting the Blocks administration screen when it's time to
05:53position blocks for our custom flower theme.
Collapse this transcript
Setting user theme permissions
00:00As we saw earlier in the chapter, Drupal can have more than one theme enabled
00:04on a site, but only administrator was able to choose the overall theme for the site.
00:09A nice feature for users is the ability to be given permission to choose their own theme.
00:15In this video, I will enable two themes and create a new generic user and show
00:20how that new user can have their own theme chosen for the site.
00:24Now, before we actually can give the user permission, we need to actually create a user.
00:28So let's do that real quick, through the Drupal Administration screen.
00:33We're going to click Users, then we're going to click Add user.
00:36We're going to create a new user, called user2, and the E-mail address could
00:42actually be something fake, so we'll say chris@local and the password,
00:48we'll just use 'user'.
00:51So we'll make sure that the user is Active, click Create a new account.
00:55Now the new account has been created for the user2.
00:58We can then go back to the administration screen, and actually enable more than
01:04one theme in the Themes administration, because we will then give the user
01:09permission to choose one of these themes.
01:12So we'll enable Marvin, click Save.
01:16So before I give the new user permissions to choose their own theme, let me show
01:20you what the user will see right now.
01:22So instead of logging out in my Firefox browser, I'm going to actually minimize
01:27Firefox and open a different browser.
01:29So I'm going to open Internet Explorer, and we're going to log in to the local site.
01:42So let's copy our URL, minimize Firefox, and now we're going to paste the URL
01:49into our other theme.
01:51Instead of visiting the Administration screen, which the copied URL will take us
01:57to, I'm going to actually trim down the URL to just visit the homepage.
02:03We're going to log in with the user2 credentials.
02:08So my Username is user2 and the Password I gave that user is just user. So click Log in.
02:14I don't want to store the password this time, and we see that Navigation is much
02:19different than our administrator.
02:21So we're going to click My account, and now we're going to click Edit, and this
02:24is actually where the user can edit their own profile.
02:27So right now, we do not see any options to choose our own theme. Let's change that.
02:32I'm going to minimize Internet Explorer.
02:33I'm going to open my Firefox, where I'm logged in as an admin, and we're going
02:40to now go to the Administer screen and we're going to choose Permissions.
02:47This is where you can actually set all the user permissions for any feature of Drupal.
02:52Permissions, for Drupal, are actually covered in detail in the Drupal Essential
02:56Training course, also available on lynda.com.
02:59So we're going to scroll down to the System section and we see that there is a
03:04permission here, Select different theme.
03:07We're going to enable this permission to the Authenticated users only.
03:12So now we click Save Permissions, permissions have been saved, let's now
03:17minimize Firefox, and reopen Internet Explorer.
03:20I'm going to now refresh this Edit Profile page for the user2.
03:26We now see that the user is given options in their profile page to choose their own theme.
03:33So let's have this user choose the selected theme for Marvin, click Save, and
03:39now we see user2 has now chosen their own theme and they're viewing the site in Marvin now.
03:46Since they are not a site administrator, they would not end up seeing the
03:49Garland theme again until we revoke their privileges, or change the theme on them entirely.
03:56So now I can actually log out, and you will see that the logged out user
04:02is viewing Garland.
04:04This is because we only gave permission to choose a custom theme to
04:09authenticated users, or people who have an account to log in with.
04:13Now going back to Firefox, where we're logged in as an admin, I actually now
04:19want to disable the second theme, because we won't need it throughout the
04:24rest of this course.
04:25So I'm going to go back to Administer, I'm going to click on Themes, we're going
04:31to disable Marvin and leave Garland as the default.
04:35We're going to click Save configuration.
04:38Now you may have noticed, I did not remove the permission of setting your own
04:42theme under the Permission screen.
04:44This wasn't necessary since we don't have more than one theme enabled right now.
04:49If you would like to remove that permission, you could do so on your own.
04:53Letting users choose their own theme is nice, but isn't always necessary.
04:57If your users need this functionality, it is built into Drupal and does not need
05:01any complex setup, as you've seen, to provide them with the ability to choose
05:05their own theme on a site.
Collapse this transcript
5. Modifying Existing Themes
Using the Color module to change color schemes
00:00Drupal 6 offers simple theme customization features without any code required.
00:06Changing the default colors for the Garland theme is easy and quick.
00:11In this video, I will explain how the color module is used to modify a
00:15default theme's colors.
00:17So to alter Garland's colors, we need to visit the Theme Administration page.
00:23So starting from the Administer screen, we click Themes, and we'll actually, now,
00:29click on the configure link, right next to Garland, so not the tab at the top,
00:36but the link in the same row as the theme.
00:39So we click configure and now we're brought to the Garland configuration screen.
00:44If you notice at the top, we have the Global settings tab that we visited in a previous video.
00:51Now we're in the Garland tab, under those settings.
00:55So we'll actually scroll down just a little bit, and as you can see, there's
01:00something pretty magical right here, which is an implementation of the color
01:04module for the Garland theme.
01:06Drupal 6 ships with a core module called Color.
01:11The Color module is available in Drupal's core for modules and themes to take
01:17advantage of, to provide things like a color wheel and manipulation to CSS and
01:23graphics from the colors chosen.
01:26Now, I want to point out that these colors that we see here are actually all
01:32defined in the theme.
01:35We can change these colors.
01:37As you see, there's a live preview update below, and even though I'm not
01:43producing a very pretty color change, I don't have to depend on my own
01:49designer skills to choose colors, because we have actually a whole set of
01:54color schemes available.
01:56So let's look at the Mercury theme.
01:58This is a nice, soft gray.
02:02Another one of my favorites is Ash, which is a nice dark theme, or we can get
02:07pretty bright and go with something like Pink Plastic. So let's do that.
02:12Let's pick pink.
02:14So this color scheme already predefines the colors and enters them in for us.
02:19We can now scroll down and click Save configuration.
02:25This site has now changed from its standard blue to the Pink Plastic color scheme.
02:30So let's visit a couple of pages.
02:32Let's go to the Home page in a new tab.
02:35We're pink all over.
02:37Let's see, services, blog, and it's all pink.
02:43One thing about this is there are some files Drupal creates, and you're notified
02:49every time you change the colors.
02:51Let's now visit this files folder that Drupal has actually entered all
02:56these graphics into.
02:58So we're going to go to our Drupal-6 installation folder, we're going to open
03:04sites, our lynda site, and go into the files folder.
03:09In here, we see a new folder added called 'color'.
03:13We go into color and we see that there is this kind of special key given to the
03:19folder name, prefixed by the garland theme and suffixed by a random key that is
03:27given at the time of creation.
03:28Let's go inside there, and now we could see all these graphics that were
03:34actually changed to pink.
03:37We also can edit the style sheets and view them to see that the colors, pink,
03:43have actually replaced every instance of blue.
03:46So Drupal did all this magic work for us.
03:48We're going to go back to the files folder.
03:52We're going to minimize our Drupal install site and while this Pink Plastic is
03:58kind of poppy, I think it'd be good if we go back to the default garland colors.
04:03Now, it would actually be really hard for me to remember what the colors were by
04:09heart, and thankfully, there's actually the default color scheme called Blue
04:14Lagoon, which is what Garland is actually built from.
04:18So we can choose this default color scheme and click Save again to then generate
04:25the blue colors in files all over again.
04:29Garland and Minnelli, which is a subtheme of Garland, are the only default
04:34themes in Drupal 6 that take use of the color module.
04:38Technically, any custom theme could utilize the color module as well,
04:43for whatever reason.
04:45But this requires some heavy PHP programming, and we will not be covering
04:49that in this course.
04:50If you don't want to get into creating a theme, changing the colors is an easy
04:55way to customize Drupal's default theme to create something unique.
Collapse this transcript
Preparing to build a sub-theme
00:00When you have a theme you like, but it needs some customization
00:03that cannot be done through the Drupal admin interface,
00:06you can build a new theme on top of the theme you already like.
00:10This is known as creating a subtheme, which means it will be built on top of an
00:16exiting theme, we affectionately call a parent theme.
00:20Producing a subtheme is the preferred method over duplicating or hacking other themes.
00:26In this video, I will explain the basics of subthemes in Drupal.
00:31If you've been following along in the previous chapters, we've already actually
00:34been introduced to a couple of subthemes.
00:37Let's see who they are.
00:38Starting from the Drupal Administer screen, click on Themes, scroll down.
00:46Two themes here, Marvin and Minnelli, are actually legitimate subthemes.
00:51Marvin is a subtheme of Chameleon, while Minnelli is actually a subtheme of Garland.
00:59Any theme could be subthemed in Drupal.
01:02Subthemes are created and installed like every other theme.
01:06Let's see what makes a subtheme tick.
01:08So I'm going to open up my drupal-6 folder, I'm going to visit the themes folder
01:15and I'm going to garland, then minnelli.
01:18I'm going to open up the minnelli.info file and I'm going to show you what
01:26actually defines Minnelli as a subtheme to Garland.
01:30This minnelli.info file is actually the theme declaration for Minnelli, so it
01:37has all the properties that Drupal is expecting to reside in the theme info
01:42file, so it can understand what is the theme, and what parts make up the theme.
01:47So a quick review, we see the name Minnelli, description, which is a long
01:52sentence, version, which we'll come back to later, core, which equals 6.x. So
01:59that means, this theme will only work for Drupal 6.
02:04We see, here, a very important line, base theme = garland.
02:09This is something that we're going to include in the next movie, into our own
02:13subtheme, since we'll be basing ours on Garland as well.
02:18So before I go on to the other stuff below the base theme property, let me show
02:23you where you can actually see a whole list of all the properties available to a theme.info file.
02:29So I'm going to visit the Drupal website, and in the Theme guide, for Drupal 6,
02:37there is a page that actually defines all the properties and explains them, so
02:42you can actually go through and choose the properties that make sense for your
02:46theme info file, and go ahead and copy-paste, and then edit as necessary.
02:51So let's actually just do a quick review.
02:54We see name, description, version, core, engine, base theme, just like we saw in
03:04the Minnelli.info file.
03:06If you scroll down little more, we actually see descriptions and examples for each property.
03:12We'll be coming back to this page when we're building our own theme.info file, in the next movie.
03:17So I'm going to go back to my Minnelli.info file, in my Dreamweaver, to show you a
03:23couple of points that you need to know about subthemes.
03:26The first is if you notice on line 7 of minnelli.info, there is a style
03:32sheets declaration.
03:33We'll be actually doing this ourselves in one of the next videos.
03:37We see that minnelli.css is used here.
03:41Well, let's go actually enable Minnelli real quick in our Drupal site.
03:46So, going back to the Theme administration page, I'm going to enable Minnelli
03:52and choose it as the default.
03:54I'm going to leave Garland enabled, and that's fine.
03:57I'm going to click Save configuration, and now that Minnelli is used for the homepage,
04:02let's visit the homepage and let's view the source now of the screen.
04:08So let's go through and see how Drupal has actually assembled the style sheets
04:13for both the parent and subtheme.
04:15Now remember, the parent theme is Garland and the subtheme is Minnelli.
04:20We can see here, in the list of CSS declarations, that there are actually a couple
04:26of style sheets for Garland.
04:28We see that themes/garland/style.css is being loaded and later garland/print.css
04:38is also pulled in, and right after the style sheet for Garland and before the
04:45print sheet is actually minnelli.css being loaded.
04:50So, as you could see, the parent theme gets its styles loaded first, and then the
04:56subtheme gets its styles loaded right after.
05:00This is because CSS provides the capability to alter styles in a cascade, and
05:07that's exactly what the subtheme does to its parent theme.
05:11So I'm going to close this source file.
05:13I'm going to actually close my preview of the homepage and reactivate Garland as
05:21our default theme, before we go.
05:23So going back to the Themes administration page, I'm going to choose Garland as
05:28the default, and I'm going to disable Minnelli.
05:31I'm going to click Save configuration, and now we've gone back to just pure Garland.
05:37One final thing I want to point out about subthemes is if you notice, Minnelli
05:42is inside the Garland folder, within Drupal core.
05:47Despite what you see here in the Drupal core, a subtheme should usually reside
05:52in its own folder, separate from their parent theme, unless the two themes, like
05:57Garland and Minnelli, are meant to be packaged together.
06:02When building subthemes based on a theme, say, downloaded from the Internet,
06:07your subtheme is dependent on that parent theme.
06:11So what happens is when the parent theme needs to be updated or changed, and if
06:17you had duplicated that theme instead of creating a proper subtheme, you have to
06:21go and apply all those changes to every instance of the theme.
06:27Instead, the proper way is to create a subtheme based on a parent theme.
06:33When any changes need to happen in either theme, they can do so without
06:38affecting any of the other themes.
06:41So let's say your parent theme needs a fix.
06:45Well, you could fix the parent theme, and then every subtheme after that would
06:50actually get the fix automatically applied upon refresh.
06:55Imagine, if instead, you chose to duplicate a theme, you would be stuck updating
07:00every copy of that theme, and that is not the Drupal way.
07:05Subthemes are good and should be always your first choice over duplicating any
07:10existing theme in Drupal.
Collapse this transcript
Building a sub-theme: Creating the .info file
00:00So after seeing what makes a subtheme tick, we can now actually go off and make
00:06our own subtheme for Drupal.
00:08So let's do that now.
00:10Remember, we're going to actually need to create a theme folder, and the
00:15theme.info file, like how we saw in the previous movie with Minnelli.
00:20So, let's make our folder and file from scratch.
00:23So, I'm going to actually minimize my Drupal.
00:27I'm going to open up my Drupal-6 folder.
00:30I'm going to go into sites/all/themes.
00:37If you have not created this folder, themes, yet in your sites/all folder, please do so now.
00:43The sites/all/themes folder is where all of our themes are going to be actually
00:48placed for Drupal to pick up.
00:51If you want something to reference, I actually have already created the
00:55subtheme, and those files are in the chapter 5 folder of the exercise files.
01:00The subtheme we're going to create is called subgarland.
01:03So, let me give you a little taste of what's inside that folder.
01:06We'll be creating these few files over the next few movies.
01:11In this video, we'll be creating the subgarland.info file.
01:15So, let me minimize this.
01:18So, if you ever want to compare what you've built to what I've completed, you
01:22could do so by looking at the exercise files.
01:25So ,let's go back to our sites/all/themes folder.
01:29We'll actually, now, create our own subtheme folder in here.
01:32So, let's go ahead and create a new blank folder and name it subgarland, because
01:38that's the name of our theme, and let's go inside this subgarland folder.
01:42In here is where we'll create those theme files that you saw in the exercise folder.
01:48So the one we're creating, in this movie, is the theme.info file, which is the
01:54most important theme file, as it's required for every theme, and Drupal will not
02:00recognize any theme folders without that file in it.
02:03So I'm going to use Dreamweaver. You could use any text editor.
02:06I'm going to say File > New, and I'm going to actually just choose a simple text file.
02:14The first thing I want to do is actually save and name this file.
02:18So File > Save As, I'm going to save this .info file inside my
02:23drupal-6/sites/all/themes/subgarland folder.
02:29This is going to be named 'subgarland.info'. Save.
02:36If we look in the subgarland folder of our sites/all/themes, we see that the
02:42subgarland.info file is saved in the proper place.
02:45So let's minimize these files.
02:48Let's start adding the text properties needed for Drupal to understand what this
02:53theme is actually called and made of.
02:56Let's go back to that page that I showed you on Drupal.org.
03:02So I have a tab ready and this is the page that defines the structure of a .info file.
03:07So this is the reference sheet you're going to want to take with you when you're
03:11building any new .info file.
03:13So remember, a .info file is plain text with some basic properties, and each
03:19property would be saved on a different line.
03:23So the properties we're going to be using for our subtheme, known as
03:27subgarland, is going to be name, description, version, core, engine, base
03:36theme, and then style sheets.
03:39So there's a few of these, and instead of typing it by hand, we should probably
03:43just copy them, right out of this page, and paste them into our theme.info file.
03:49So the first property, which is required, is name, so I'm going to go back to
03:53Dreamweaver after copying that property, I'm going to paste, and let's edit this
03:58to say Sub-Garland, new line, and then save.
04:05Go back to the reference page and let's pull description, copy, go back to the
04:13text editor and paste.
04:15Let's update this description to say 'A custom subtheme for Garland'.
04:21That looks good, new line and save.
04:26Go back to the reference page.
04:28Let's now get version copied, and let's paste that into our text editor.
04:36Now, version is the version of the theme, not the version of Drupal that the
04:42theme will be running on.
04:44So this version number, it could be anything you want.
04:47In fact, we're going to stick with the version 1.0.
04:50If you ever change this theme, you can update the version, as you want to, to be
04:55say 1.1 or even 2.0.
05:00For this video, let's leave it at 1.0. Create a new line and save again.
05:06Go back to Drupal's reference of theme.info files, and the last few properties
05:13we need are core, so let's copy that, paste.
05:18Remember, core actually refers to the Drupal version that the theme will be running on.
05:24Remember, only a Drupal 6 theme could run in Drupal 6.
05:29So core is for Drupal and version is for the theme itself.
05:34So don't confuse the two.
05:36Make a new line, click Save, go back to the reference.
05:41Let's grab engine, which equals phptemplate, and we're going to leave that value the same.
05:48So Paste, create a new line and save.
05:51Let's go back to the reference and now we need base theme.
05:56So let's grab base theme, copy that and paste that into our
06:01subgarland.info file.
06:03I personally like to separate the base theme line from all the other
06:07properties up on top.
06:08Now this is just me, but this is not required, so you can actually remove any of
06:14the white space you see between each line.
06:17Base theme for us is going to equal garland, as that is the theme ID name
06:23for the Garland theme.
06:25If we were going to base our subtheme on a different theme than Garland, you
06:29would have to look at that theme's .info file name and then take the file name
06:35and use that as the base theme value.
06:38So, if we instead, wanted to maybe use pushbutton as the base theme, we would use
06:45the word 'pushbutton'.
06:46Instead, we're going to use garland, of course, create a new line and save.
06:52So, now we've actually created the standard properties a theme.info file
06:58requires to be picked up by Drupal.
07:01So let's go and actually try enabling this subtheme and let's see what happens.
07:06So I'm going to go back to my Drupal.
07:07I'll minimize my text editor, and starting from the Administer screen, we're
07:13going to click on Themes.
07:15If you scroll down, you should now see Sub-Garland actually appear with the rest
07:19of Drupal core themes.
07:21If you do not see Sub-Garland here, that means you did not actually complete the
07:28file name correctly or you messed up one of the properties somewhere.
07:33So make sure that that text is correct.
07:35You could refer back to my exercise files of chapter 5 to see what might be
07:40different between your theme.info file and mine.
07:44So we're going to enable Sub- Garland and choose it as the default.
07:49Click Save configuration, and we see Drupal has given us a message, saying
07:55the administration theme is still set to garland, but the front end, it will be subgarland.
08:02So that's good, but let's go see what subgarland looks like right now.
08:06I'm going to open the homepage in the new tab.
08:09We're going to visit it.
08:11As we see here, this does not look like Garland.
08:16In the next video, we're going to actually be adding a style sheet, which is a
08:20required property for a subtheme to start picking up styles.
08:26There is an issue here, where the subtheme needs at least one CSS file declared
08:32before it could pick up the other parent theme styles.
08:36So right now, the subtheme is rendering without any custom style sheets, or any
08:42of the parent's style sheets.
08:44We'll actually need to fix this by adding one custom style sheet.
08:48So let's do that in the next video.
Collapse this transcript
Building a sub-theme: Adding custom styles (CSS)
00:00So, picking up from our last movie, we've already created the subthemes.info file
00:06which lets Drupal know that the sub-theme exists.
00:09But as we saw in the last movie, we still needed to add our own custom style
00:14sheet, so it could be picked up along with all the parent style sheets.
00:19So I'm going to edit the theme.info file to add a style sheet property.
00:24So first, let's actually go ahead and see what that property will look like.
00:29So going back to the Structure of the .info file webpage in the Drupal theme
00:35handbook, we're going to now go down to the property for styles and that's style sheets.
00:43So, let's copy this property.
00:46Let's go back our text editor.
00:48Remember, I'm using Dreamweaver and we'll now paste in this declaration line
00:54into our theme.info file.
00:57So if you've been following all along from the last movie, we've been building
01:00this subgarland.info file.
01:03This version of the file is actually not in your Exercise Files folder because
01:08that's the completed version of the sub-theme.
01:10So you can go back and refer to that file if you want to see what the
01:15differences between your version is from the complete version.
01:19So I've pasted the line of text that declares a style sheet for our sub-theme.
01:25We need to edit this to actually reflect our own style sheet file.
01:30So let's go and look at the sub- theme that's completed, in the Exercise
01:36Files folder in Ch 05, in subgarland and we see that I've actually named the file 'custom.css'.
01:46So I'm going to minimize this folder and I'm actually going to edit the .info
01:50file to say custom.css for the style sheets declaration.
01:55Make sure you create a new line and click Save.
02:00Let's go back and refresh Drupal to see what happens.
02:05So I'm going to the tab that is the homepage of our Drupal site.
02:09Now I'm going to click Refresh, and you're going to see that nothing will change
02:14and this is because Drupal has its own internal cache for themes.
02:20So we need to flush the cache, and by doing that, we will then see all the new
02:26changes in our Theme folder.
02:28So to do that, we need to go back to our Drupal theme administration page and
02:33actually just refresh the theme administration page.
02:38Very simple, and it is a little bit of a nuisance, but it's for
02:41performance reasons in Drupal.
02:43So let's go back to the homepage, now that we've refreshed the theme
02:47administration page and essentially cleared the theme cache.
02:51We can now refresh and we see, now, that there are styles applied all over this page.
02:59Let's view the source and see what Drupal is now doing.
03:02I'm going to right-click, View Page Source, and I'm going to on a call out the
03:07garland styles first.
03:09So we see that there is garland/style.css and garland/print.css, but where is
03:17our custom.css file?
03:20We declared it in the theme info file, but we did not create a file for Drupal to
03:26actually pick up and load.
03:27Drupal is very smart and actually will recognize that the file is missing and it
03:32will not output any markup that will point to a broken file.
03:37So let's go and actually create an empty custom.css file for Drupal to pickup.
03:42I'm going to go and close the source file that we see here.
03:47Going back to my text editor, look at the file name that we wanted to be
03:52declared, custom.css.
03:55Now I'm going to say File > New, and I'm going to actually create a new Blank
03:59CSS file and I'm going to save this as custom.css and make sure that it gets
04:09saved in my sites/all/themes/ subgarland folder. Click Save.
04:15Now I'm going to view the folder just to make sure. I see the custom.css files now there.
04:23Let's go back to Drupal, let's refresh and see if Drupal picked it up.
04:29So I refreshed the homepage. Remember, this is running our subgarland theme.
04:33I'm going to view the Page Source, and now if we look, we can see that the
04:38garland style sheet style.css is there, and then of course garland print style
04:44sheet, and in between, we notice there is a new style sheet.
04:49And this is our subgarland/custom.css file.
04:54And again, Drupal noticed that there was an actual file there, so it made all the
05:00markup necessary to bring this file in as a style sheet.
05:04And just as it's expected, it actually provides this style sheet listed after
05:09its parent style sheet and that's using the cascade feature of CSS.
05:15I want to point out one more thing about style sheets and sub-themes.
05:20I named my subgarland style sheet custom.css.
05:26I could've named it style.css, similar to how the parent theme is set up.
05:32But when you use the same style sheet name as a parent theme, Drupal will
05:38actually notice that both the parent and sub-theme style sheets have the same
05:42name and assumes you want to actually totally override the parent theme.
05:48So if we named subgarland's style sheet style.css, garland would actually not
05:55be allowed to render its style.css at all.
06:00Since we want to actually build on top of garland's style sheets, so that's why
06:05I named our subgarland style sheet custom.css and not style.css, because I want
06:12both style sheets to load.
06:16Let's go and try adding a custom style that we can actually see help change the
06:23front end of our Drupal site.
06:25So I'm going to go back to my Dreamweaver, I'm going to add a new style here,
06:30custom.css, and I'm going to say for the body, let's actually change the color of
06:38all the text to be red.
06:41Now I'm not going to keep this.
06:42I just want to see if this is actually going to change for us.
06:47So I'm showing you a quick simple change by adding just a single declaration for
06:54body color inside the custom.css file.
06:58And of course, since our sub-theme style sheet gets loaded after the parent
07:03theme, our body color takes priority.
07:07So now I'm going to remove that style because really, the red doesn't work for us.
07:12So let's delete these styles and leave this file empty, so for the next video,
07:17we can actually add a new custom style for a new theme region, we're going to
07:23the sub-theme.
Collapse this transcript
Building a sub-theme: Adding custom theme regions
00:00All Drupal sites have blocks and these blocks get positioned in what are known as regions.
00:06The regions most people are familiar with are the left and right sidebars
00:10that appear in Garland.
00:12In this video, I will show you how to add an extra region to our sub-theme by
00:17editing only a couple files.
00:19So since we are building a sub-theme, based on the Garland theme, we would
00:24actually need to make sure that we know what regions are already defined in
00:28Garland. That could be done in two different ways one ways.
00:32One way is we can check the Blocks Administration screen, so I will open that in a new tab.
00:38Go to the Blocks page and we could see the list of regions that pop up for
00:45Sub-Garland, because Sub- Garland is a sub-theme to garland.
00:50So we are picking up the regions that are already defined there.
00:55We see that there is a Left and Right sidebar, there is the Content area,
00:59a Header and Footer.
01:01So we will need to duplicate these regions in our own theme.info file, so we
01:07can add one new one.
01:09So let's go and do that now.
01:10So I am going to close the Blocks Administration screen. Now, I want to refer
01:15back to the Drupal Theme Guide for Drupal 6,
01:19the page known as Structure of the .info file.
01:23This is a whole reference sheet of all the properties that can be entered into
01:28a theme.info file.
01:30We have been using this page for the last couple movies and we are going to use
01:33it again for this movie, so we can learn what the region syntax is.
01:38So I am going to scroll down and we see that there is the Regions property
01:41listed here, we can click this and it will take us down to the list of regions.
01:48This is the format that Drupal will expect to see what regions your theme
01:54defines within the theme.info file.
01:57There is a certain format. The word 'regions' is used and then there is these
02:02brackets, within the brackets are the region IDs.
02:07These region IDs are important and should only be lowercased, should not contain
02:12any special characters or spaces.
02:14The name of the region ID, which is full standard text, could be whatever you need it to be.
02:21It could the mix case and as you see for Left and Right sidebar, there is a
02:26space in the name, which is totally valid.
02:28We are going to duplicate this set of regions and create one new custom region.
02:34Now Garland has these five regions defined.
02:38Let me show you garland's .info file and let's see if it declares any regions in
02:44that file, which should be expected.
02:47So, I am going to actually go to my Drupal folder, themes, garland and we are
02:54only visiting this folder to view the garland.info file.
02:58So I have just opened garland.info in my Text Editor, which is Dreamweaver, and
03:03I am looking for that regions syntax, but I don't see it here.
03:07And the reason is if you don't declare any regions at all, Drupal will assume
03:14that you actually want to use the standard five that are listed here: Left,
03:20Right, Content, Header and Footer.
03:22Well, for Garland, that is the case, but our sub-theme, we want one extra region.
03:29We cannot define just one region in our sub-theme because then Drupal will then
03:35assume that you actually only want one single region in your theme.
03:41So we will copy the regions code, take that in to our Text Editor and we are
03:46going to paste it into the subgarland.info file.
03:50So I can close the garland.info because we are not using it anymore.
03:55So now I am going to actually paste in the region syntax for our theme.
04:00So these default five regions are now in our .info file, but we want to add one extra one.
04:07So let's actually duplicate the content line for regions and come up with a new
04:14region called content_top.
04:18So for the region ID, I am going to add an underscore, but for the name, I am
04:23going to use a space.
04:25You need to make sure that every region ID is unique.
04:29That's why we're adding _top because otherwise we would just be confusing Drupal
04:35by trying to define two content regions.
04:38So let's make sure we have each one on their own line, click Save and now we
04:44can actually start to add the code that Drupal is going to expect to appear in this region.
04:52And where does that code go?
04:54Well, in the next chapter we are going to be diving into more things like
04:58the Page Templates.
05:00So since we're basing our sub-theme on Garland, which comes with Drupal 6, we need
05:06to visit that theme folder for Garland and actually pull out its Page Template,
05:11because that's where the regions markup code is actually defined.
05:16So let's go get that file.
05:17I am going to go back and visit my garland folder. That's in
05:21drupal/themes/garland. Now, I am going to look for a page.tpl.php file and here it is.
05:31So let's actually copy this file over to our subgarland folder. We are just
05:36going to, literally, duplicate it.
05:39We are not going to rename it because it needs to stay page.tpl.php.
05:45I am going to actually open this file in Dreamweaver, in my Text Editor.
05:51I am going to flip to Code view and now we are going to look for the content
05:57region, because we are going to actually add Content Top right above that.
06:02So I did a quick search for the region ID of content and it brought me to line 76.
06:10In here, I am going to actually add a whole new div with an ID called Content
06:16Top and I'm going to duplicate the syntax used to actually enter in the dynamic
06:23code for that region.
06:25You'll see what I'm talking about in just a second.
06:27So what I want to do is I actually want to duplicate lines 75 through 77 of
06:34this Page template file.
06:36So I am going to Copy, I am going to create some space above that tag, I am
06:43going to Paste and I am going to fix up this code real fast and we are going to
06:49give it an ID of content-top.
06:55Remember, the region id that I declared in the subgarland.info file is formatted
07:03content_top, because that's going to end up turning into a PHP variable, so we
07:09can't use a hyphen there.
07:11But for CSS, we do want to use a hyphen and we are going to declare this style
07:16a little bit later.
07:17We are going to keep the class style and we need to change the PHP variable
07:22that is listed here, to be content_top.
07:26I don't want to leave this code just like this because, in Drupal, you can
07:30actually have a whole region be collapsed and disappear from the page when there
07:37are no blocks assigned to it.
07:39We want to follow that same convention and to do that, we have to grab just a
07:44little bit of extra PHP and wrap it around each of these divs.
07:50So I am going to actually copy line 89, which is a php if statement.
07:55So it says php if, and this one says right, so I'm going to copy this and I'm
08:02going to paste it above the declaration of my content-top div.
08:06I am going to copy the content_top PHP variable and replace the text that says
08:14right with my proper content_top variable.
08:17We need the endif for this statement because once you start an if statement in
08:23PHP, you have to finish it.
08:25So we will copy right here, line 94. I will paste it up on line 80, and now, this
08:33is a valid if statement, or conditional logic statement in PHP and it's saying if
08:40there is content within content_top, then go ahead and place all this markup in
08:47the page. Otherwise, don't have it show anywhere at all.
08:51I am going to Save this page template file.
08:54I am going to now go back to my Drupal site.
08:59So we click the tab and now I need to refresh the themes page, so Drupal can
09:07actually catch on that we did a change.
09:10So I click List or I can click Refresh.
09:14Another safe way to make sure that Drupal will pick up your changes is to make
09:20sure your theme is selected as the Default and Enabled and clicking Save
09:24configuration again.
09:26This is almost in a way kind of like telling Drupal, Hey!
09:30Go and check all the theme folders again for me real quick and Drupal will do that.
09:35We need Drupal to do this so it recognizes that a new file was actually added
09:40and a new region was declared within our theme folder.
09:45So let's actually go ahead and now see how our new region gets displayed in Drupal.
09:51The first area I want to point you to is the Blocks Administration page.
09:56So visiting the Blocks Administration page, we should now see the first
10:00preview of Content Top, up here, because the Blocks Administration page
10:06creates these kind of preview divs, so you can see where your blocks are
10:12going to appear in those regions.
10:14So we see, now, I have whole new region here, called Content Top, and in fact, you
10:20can even see it listed, right here, where I've highlighted, and we can actually now
10:25place blocks right into this region.
10:27So let's do that, now.
10:28I am going to add the Who's online block to our new Content Top region.
10:36So I chose Content Top, the block looks like it's going to go there.
10:40So we click Save blocks and now we see that the Content Top region has our Who's
10:47online block placed. This is excellent.
10:50Let's actually, really quick, flip over to the Garland blocks and we see this
10:56region is only appearing content top for our sub-theme.
11:01Go back to Sub-Garland and we see that that's the case.
11:05Remember, a new region must be declared in both the theme.info file and the
11:11page.tpl.php template.
11:15We built a new custom region on top of the standard five regions that Drupal
11:20assumes is in every theme.
11:23We made sure we added all five of the regions in our .info file.
11:29We made sure that we declared our new region along with the standard five
11:35because Drupal would assume that if we only put in one region declaration that
11:40our theme only had one region and that's not the case.
11:43There is no limit on how many regions can appear in a theme.
11:47To many people, flexibility in the theme usually comes from the amount of regions available.
11:53The more regions that appear in a theme, the more places that you can
11:57position blocks into.
11:59Defining additional regions in sub- themes really helps to show how building on
12:03top of an existing theme is always a good idea.
Collapse this transcript
6. Creating New Themes
Exploring a theme folder
00:00Drupal themes are packaged inside what's known as a theme folder.
00:04Making sure you name this folder and its files correctly are key to a
00:08theme working properly.
00:10In this video, you will learn what folders and files should be expected within a theme folder.
00:15So the Theme folder I have in front of us is actually a fake theme.
00:20All these files are empty but what's inside of them is not important as how they
00:25are named is the key piece that you need to learn.
00:29A theme folder name should not have any special characters except underscores
00:34and it should be usually lowercased and as you see up in my address bar that's
00:39what I've done for this theme_folder.
00:41A theme folder name should not have the same name as say a module.
00:46So you do not want to have a theme named comment because there is a comment
00:51module built into Drupal.
00:54Inside a theme folder the first file that is looked at by Drupal is
00:59the theme.info file.
01:01So right here this file I have named my_ theme.info, which is a legitimate file
01:09name and you would make sure that your folder is named the same.
01:14Now I have them named differently the only example purposes.
01:19Now Drupal will actually pick up this theme info file and it will register the
01:24theme internally and allow you to enable a theme.
01:28Without this info file there is technically no theme.
01:32The next two important files are our CSS files.
01:35Here we see I have style.css and print.css.
01:40Print.css will only load for printers while style.css is used by our web browsers.
01:47The next set of important files are usually images and the images go in a
01:51folder called usually images- makes sense- and these images are usually used by our style sheets.
01:59The next set of files I want to introduce are the templates.
02:03So here I have three templates I am highlighting, Page, Block and Node.
02:10These are all covered in their own chapters and they're very important as they
02:14each define the markup for their own designated area.
02:18There are a few small files here, which are the favicon for the theme, the logo
02:24for the theme and the screenshot for the theme.
02:27These are optional but they're quite common.
02:30The other two files that I want to show you are template.php
02:35and theme-settings.php.
02:38These two files will not be built in this course, but I want you to know about
02:42them because they appear quite often in themes that you might download from the Internet.
02:47The template.php file has some PHP logic that the theme uses.
02:53This is not a template this is literally a PHP logic file.
02:58The same goes for the theme-settings.php file.
03:01This is something much more advanced and usually programmers develop these files.
03:07Keeping a theme folder organized is important because it is very easy for a theme
03:12folder to get bloated when working with a lot of theme files like multiple
03:16templates and style sheets.
Collapse this transcript
Setting up a theme .info file
00:01For Drupal to recognize a theme exists, a declaration file is required, known
00:06as a theme.info file.
00:08Like we saw in the previous chapter, a theme.info contains all the details about
00:13the theme, like the theme name, its version and style sheets.
00:17In this video, I'll be preparing the .info file for our custom flower shop theme.
00:23So to get started, I don't actually need to do anything in Drupal, the
00:27Administration, but I need to set up some folders and files in the Drupal site.
00:32So let me minimize my browser. I am going to open up my drupal-6 folder.
00:37I am going to go into the sites/all/themes folder.
00:41If you don't have a themes folder inside your sites/all folder, go ahead and
00:45create it now, because this is where all our themes will go inside.
00:49So we'll actually now create a new theme folder.
00:53So this is actually going to be called hanselandpetal, which is the name of our flower shop.
01:01And we are going to actually go inside of this folder, and in here is where we
01:07are going to create all our custom theme files.
01:09So the first file we need to create always is the theme.info file.
01:14Now, this is a simple text file, and I am going to show you a webpage that
01:18actually outlines the details of this .info file used for themes.
01:24So this is the page in the drupal-6 Theming Guide.
01:27This page covers all the details of a theme.info file's syntax.
01:31It's very simple, and we actually covered a bit in the previous chapter, but
01:36if you're just joining us, then I need to just tell you that we are going to
01:39be using these properties listed here on this page, not all of them, but most of them.
01:45And we'll be actually using a lot of the stuff that you see in the descriptions
01:50that are below the list of properties on this page.
01:53So let's go to our text editor.
01:55I'm using Dreamweaver, and let's start a new file that's text, and
02:01we should start by saving it.
02:03So let's go File > Save As and let's choose our Drupal sites/all/themes folder
02:11and to get inside our hanselandpetal theme folder, and we are going to actually
02:15name this .info file, hanselandpetal.info.
02:20So now let's just validate that Dreamweaver wrote this file in the right place.
02:27And now that we have this theme.info file ready for us to start editing, we can
02:31start placing the theme properties that we need for our custom theme.
02:36So to get us going a little faster, I am going to actually copy some syntax
02:40that's already prepared in the Exercise Files in Chapter 6.
02:43So I am going to visit my Exercise Files, Chapter 6, and if you don't have the
02:49Exercise Files, you can pause the video after I've pasted the code in,
02:53to actually copy it on your own screen.
02:55So I am going to open the exercise version of hanselandpetal.info.
03:00I am going to copy this code.
03:02I am going to close this sample file.
03:04Now, I am going to paste and just to give you a quick review, we have the theme
03:09name, the description, the version number of the theme itself, the required
03:16Drupal version known as core, the engine, a screenshot and all of the regions
03:22that are defined for our theme.
03:24We covered regions in the previous chapter and we will be going into detail in
03:29the next chapter as well.
03:31So I am actually going to save this file, but we are not going to enable the theme just yet.
03:37Because if we did so now, we would have one big blank white page, because
03:42there's no styles declared for this theme yet.
03:44We will be actually doing that in the next movie.
03:48So what we've created here is the theme manifest file.
03:51This is a required file for Drupal to actually recognize that you have a theme
03:56that it should pick up.
03:58Without this file, Drupal can never know about your theme.
04:02So this is always going to be the first file you create when developing a new theme.
Collapse this transcript
Adding styles (CSS) to a theme
00:01Each theme has style sheets that get applied to every page.
00:04The way style sheets are added to Drupal is different from how you normally
00:08add CSS to HTML pages.
00:11In this video, I will be showing you how to add a custom style sheet to Drupal,
00:15which will then allow us to enable our new theme and see how it renders so far.
00:20So the first thing we need to do is actually create a style sheet and we are
00:24going to do that in our favorite text editor.
00:26For me, that's Dreamweaver.
00:28So I'll actually say File > New.
00:31I am going to choose CSS and I am going to actually just save this file first
00:37before we add anything to it.
00:39So I am going to click File > Save As and I am going to make sure I'm saving
00:43this file inside my drupal, sites/all/ themes/hanselandpetal folder, because this
00:50is the folder of our theme, so this file is going to be called style.css and
00:56we are going to click Save.
00:56Now, let's make sure that Dreamweaver put it in the right place.
01:00We see that it's definitely in our sites/ all/themes/hanselandpetal folder. Good!
01:06So minimize the folder, and now I have some styles already prepared in the
01:11Exercise folder of Chapter 6, so we don't have to sit through and actually type
01:16all these styles out.
01:17Let me go get that file.
01:19So in the Exercise Files, Chapter 6, there is a style.css file.
01:25So let's go ahead and open that.
01:26So you can find this CSS file in your Exercise Files folder.
01:31You'll need to copy and paste the contents of this file completely into the new
01:35style.css file that we just created for our theme.
01:39If you're not a premium member of lynda.com, you do not have access to
01:43the Exercise Files.
01:45Since this file is essential to completing this project, we have included it as
01:50a free exercise file.
01:51You can download this file from the course page.
01:55So let's copy everything, so we Select All > Copy, go to the style.css file
02:02that's in our theme folder, and we are going to paste, and let's Save.
02:08And now that this file is prepared, we can go back to our hanselandpetal.info
02:13theme file and actually declare this style sheet within this .info file.
02:18So we are going to go to the bottom and create a new line.
02:22I am going to pull out my .info file reference sheet from the Theming Guide on drupal.org.
02:28This page shows all the possible properties a theme.info file can have.
02:34And we used this throughout the previous videos. This time we are going to
02:38use the style sheet property to actually declare our style.css to be a part of our theme.
02:44Scrolling down to the stylesheets property, we see that there's some code that
02:49I am going to copy, go back to my theme.info file, I am going to paste and I am
02:57going to edit this line to reflect our own style sheet, which is style.css.
03:01I am going to create a new line and I am going to click Save.
03:05So now that we have the style sheet declared in our theme info file and we've
03:09actually prepared the style sheet file, we can go back to Drupal's
03:12Administration screen and actually enable our theme.
03:16We are missing quite a few parts, so it's going to look a lot different than
03:20what the final theme looks like.
03:22But we'll be building the rest of the theme throughout this course.
03:26So before we go back to Drupal to enable our custom theme, there's one more file
03:31that I've actually declared in my hanselandpetal.info file.
03:36This file is a screenshot graphic.
03:39So line 7 that I've highlighted here says that the screenshot.png file will be
03:45loaded for this theme within our Administration area.
03:49I would like to make that happen, so I'm going to copy from my Chapter 6 Exercise Files folder,
03:56the screenshot.png file into my theme folder.
04:01So I am going to copy that over and I am going to minimize the Exercise Files.
04:04I am going to minimize now the theme files and we can go to Drupal, enable our
04:09theme and see how it renders so far.
04:12So I am going to go back to Drupal and we already have our Theme
04:15administration page loaded here.
04:17Let's click Refresh, so Drupal can pick up the new changes to our theme.
04:21We are going to scroll down and we see that we have our Hansel and Petal theme
04:26showing up here, also with the screenshot. Looks good.
04:30Let's enable this theme by clicking Enabled and actually choosing it as a Default theme.
04:35Now, before we click Save configuration at the bottom, I want to remind you that
04:39we already set the Administration theme to Garland in a previous video.
04:44Whenever you create a new theme or you download a theme, always set your
04:49administration theme to something like Garland first, so you can safely get back
04:54into your site if you accidentally lock yourself out, because your new theme was
04:58missing something important.
05:00I am going to click Save configuration and Drupal has notified us that the
05:03Administration theme is garland while our front-end theme is hanselandpetal.
05:07That's what we want.
05:09Now, let's preview what this looks like.
05:11So I am going to open a new tab to the homepage.
05:14I am going to view it and while this doesn't look pretty, it's definitely the
05:18start of our own theme.
05:20We see a lot of the styles have been applied.
05:23We can scroll down and we see most of the original design appears.
05:28Throughout the rest of the course, we'll be building the other pieces that are
05:31missing to get this theme to look right.
05:34One more point about style sheets in Drupal.
05:37Let me go back to my Dreamweaver and I want to actually go back to the style.css file.
05:43There is a common technique to load multiple style sheets known as the @import.
05:50Well, Drupal recommends that you do not use @import in your style sheets, but
05:56instead declare every style sheet in your .info file for your theme.
06:03The reason Drupal would prefer you to actually declare every style sheet
06:07separately in the theme.info file is because it will take all your style sheets
06:12later at the end and we can compress them so your site can actually run very
06:17fast by not having to load a bunch of different style sheets.
06:22If you use @import, Drupal does not know about these other style sheets and then
06:27cannot compress them together.
06:29So this is a performance thing and is totally optional, but it's
06:33highly recommended.
06:35One final point about styles. If you are actually creating a theme that has a
06:39lot of style sheets, you can put all the styles into a subfolder like maybe CSS or styles.
06:48Whatever you name that folder, be sure to come back to your .info file
06:52and update the path.
06:55Since we only have a couple of style sheets in this theme, I don't need to put
06:59them in a subfolder on their own.
07:01With our main style sheet now being rendered, we can move on to adding the other
07:05style sheets that usually accompany a Drupal theme.
Collapse this transcript
Including a style sheet for right to left readers
00:01Some cultures do not read content from left to right but instead they read right to left.
00:06Built into Drupal's Theme layer is the ability to include a right to left
00:10style sheet very easily.
00:12In this video, I will show you how to add a right to left style sheet in your own themes.
00:17So there are no files that we really need to edit, like we just did in the
00:22previous video, to create a right to left style sheet.
00:25In fact, we do not need to declare a right to left style sheet within our theme .info file.
00:31Instead Drupal is going to look for a certain naming convention with every style
00:37sheet in your theme to find the right to left version of the style sheet.
00:41So let me show you how that's done.
00:43I'm going to visit to my theme folder.
00:46So I'm in the hanselandpetal folder that's inside of site/all/themes, and to
00:51produce a right to left style sheet, we need to just duplicate the style sheet
00:56that we wish to have available to right to left people and append to the file name -rtl.
01:04So any style sheet you have in your theme, if you create a duplicate of it,
01:09change its filename to end in -rtl, Drupal will automatically pick that up later
01:15when somebody comes to your site viewing your theme in a browser that is reading
01:20content from right to left.
01:23Since I will not be including this right to left style sheet in my own theme here,
01:27I'm going to actually remove it before we go.
01:30Well, not every site is designed for right to left readers in mind, Drupal's
01:35easy solution to support right to left in themes is a great move for a site to
01:40have a global audience.
Collapse this transcript
Creating a print style sheet
00:01Built into CSS is the ability to have separate styles for different media
00:05types like printers.
00:07Drupal supports all media types in CSS.
00:10In this video, I will show you how to include a print style sheet with your Drupal theme.
00:14So to add a print style sheet to our Drupal theme, we need to first actually go
00:20to our theme.info file.
00:23In here is where we're going to declare our print style sheet.
00:26And the line of code is actually very similar to line 18 that declares our
00:31standard style sheet.
00:33Let me show you the syntax that we're going to use for the print style sheet.
00:37So I'm going to duplicate this line of code and I'm going to change the all
00:43media type property to print.
00:45I'm also going to change the style sheet to be print.css.
00:50Now, I'm going to Save this file.
00:52Let's create this print style sheet real quick.
00:56File > New > CSS and I'm going to Save this file inside my themes folder, which
01:03is in sites/all/themes/hanselandpetal.
01:03This is of course being called print.css.
01:11Let's double check that Dreamweaver put in the right place and so it did.
01:15I'm going to minimize this folder and I have a couple of styles already prepared
01:20for me in the Exercise Folder of Chapter 6.
01:23So I'm going to open my prepared print style sheet already and as you can see
01:28it's very small, so I'm going to Select All, Copy and Paste into my
01:35theme's style sheet.
01:36I am going to click Save and I'm going to close the example sheet.
01:40If you do not have the exercise files for this course, you can actually pause
01:44the video right now and copy these lines of CSS for your print style sheet.
01:50So now that I have my print style sheet file ready and my theme.info file
01:55updated, we need to let Drupal know that there has been a change to our theme.
01:59And we do that by refreshing the Themes administration page to clear the theme
02:04cache within Drupal.
02:06Let's go and actually visit the homepage again and remember this is in progress,
02:11so the site doesn't look like the final design yet.
02:14I'm going to Refresh this homepage and we're going to now view the source of
02:18this page and we're going to see that the two style sheets declared in our theme
02:24are outputted in the head code of the page.
02:27We see that the all style sheet is our style.css and we see a new media type for print,
02:33which points to our print.css file and that's exactly what we want.
02:39So let's get a preview by doing Print Preview within the browser and see how
02:44it's going to look when it's printed.
02:46As you can see, it looks a lot different than the screen version.
02:51In fact, it looks different on purpose because our print style sheet removes all
02:57the background colors that would end up wasting somebody's ink.
03:01So we change it to be just white and the front text, we try to make that black.
03:06A lot of people print web pages, so it is a good idea to include a print style
03:12sheet with your themes, but it's not required.
03:15I recommend providing a print style sheet that changes your site to have a white
03:19background with black text, reducing the amount of ink needed to print any page.
03:25This will provide a better experience both on and off the web.
Collapse this transcript
Adding JavaScript to a theme
00:00If your Drupal theme needs to include JavaScript files for whatever reason,
00:05you will need to declare each script within your theme.info file.
00:09In this video, I will show you the proper way of how to add JavaScript files to a Drupal theme.
00:13The graphic designer that designed the flower shop theme has requested that we
00:18utilize a couple of free scripts found on the web that will help make sure that
00:23columns end up the same height in a certain region.
00:27Since Drupal 6 comes with the JavaScript Library known as jQuery, these scripts
00:33are actually jQuery plug-ins.
00:35Let me show you the scripts that we will be using in this video.
00:38The first is this Equal Heights script.
00:41And the second script is a Pixel-to-EM Conversion script that the other Equal
00:46Heights script actually requires.
00:49So we will be downloading both of these scripts into our themes folder.
00:54So let's scroll down.
00:56Let's find the code we will be saving.
00:58So here is the jQuery plug-in called Equal Heights.
01:02So I am copying the code, and I will be actually declaring a new file in my Text Editor.
01:09Remember these will be JavaScript files.
01:11So I am starting with a blank JavaScript file, and I am going to paste in the
01:17Equal Heights script.
01:18Now I am going to save this file into my theme folder, which will be in my
01:24Drupal site, sites/all/themes/hanselandpetal.
01:34And for JavaScript files, I like to keep them in their own separate folder
01:38within my theme folder.
01:40So let's create a new folder, call it js for JavaScript, and let's name this
01:45file equalheights.js.
01:50Let's make sure Dreamweaver put it in the right folder.
01:53We see our hanselandpetal theme folder now has a js folder, and in there is
01:58an equalheights file. Good.
02:01Let's go get the second script.
02:03The second script, we don't actually copy out of the blog post, but
02:06instead download it.
02:07So let's grab this file by right clicking, Save As, and saving this file into
02:13the same folder as our new equalheights.js file. Good.
02:20So now, let's actually create one more blank JavaScript file, and this is going
02:24to be the glue for our theme to utilize those scripts we just downloaded.
02:29I am going to type this code by hand, so you can follow along.
02:33So this is some jQuery code that will actually run when the page is ready to load,
02:40and this script will actually be targeting a new region we will be adding
02:45later called footer-content.
02:51So I am going to fix the formatting very quick, and I am going to save this file as ready.js.
02:58I am going to save it with the other two script files in our theme folder. Good.
03:02So now let me close the JavaScript files we have created, and let's see how
03:07we actually add these now to our theme manifest file, otherwise known as our theme.info file.
03:14So now there is a certain syntax we need to enter into our theme.info file that
03:19declares JavaScript files.
03:20I am going to open my web browser, and I am going to visit a page on drupal.org,
03:26which defines all the structure properties for a theme.info file.
03:31We have been referring to this link in the last few movies.
03:35So let's scroll down and let's find the scripts property.
03:39We see here it's a simple line.
03:41I am going to highlight. Copy.
03:44Go back to my Text Editor, and I will paste this line into my theme.info file.
03:51Now, obviously our JavaScript files are named differently, so let's edit this line.
03:55So the first one we have is js/equalheights.js.
04:04The js/ is actually the JavaScript directory we created in our theme folder.
04:10The second script is actually called pxToEm.
04:16Let me actually copy the file name, so it's easier to paste.
04:20And there is a third script line we need to add, which is the JavaScript
04:25we coded by hand, known as ready.js.
04:29So I am going to click Save on this theme.info file, and now we have our three
04:35JavaScripts actually declared for our theme.
04:39We can go back now to our Drupal site, and of course, because there is a
04:44big change now in our theme manifest file, we need to let Drupal know about that change.
04:50We do that by refreshing the Themes Administration page, and now if go back to
04:57our Homepage tab, we can Refresh and check the View Source to now see our three
05:04JavaScript files load as expected.
05:08Here is our equalheights.js, here is the pxToEm.js, and here is the ready.js.
05:15Now, right now there is no noticeable change on our homepage by adding these
05:20JavaScript files because we are still developing the theme.
05:24Near the end, when the theme is almost complete, we would be able to see these
05:29JavaScript files in action.
05:32So now that we have our JavaScript files loading with our theme, we can actually
05:36now start to move on to the final pieces that are needed, like templates.
05:41If you would like to learn more about jQuery or JavaScript, you can view the
05:45Essential Training titles for both on lynda.com.
Collapse this transcript
Adding graphics and images to a theme
00:01Since our Drupal theme will inevitably have graphics included with our CSS,
00:05we should prepare our theme to be ready for these images.
00:08So let's get started.
00:10Since themes are strictly for presentation in Drupal, we only want to include
00:14the graphics that make up our theme, which is essentially anything that is going
00:19to be part of the design and look of the site, not any of the content imagery
00:24that you might see in say nodes or blocks.
00:27So let's actually prepare an images folder, because Drupal themes can
00:32utilize subfolders.
00:35So jumping into our theme folder, and remember our theme is called hanselandpetal,
00:39located in the sites/all/themes folder,
00:44we create a new subfolder called images.
00:48We can place all our theme images in this folder.
00:52In fact, I have a bunch of files already ready that are included with the
00:56exercise files for Chapter 6.
00:57So I want to go in here and I'm actually going to copy all of these images into
01:04our theme, and we can go back to Drupal and refresh our homepage.
01:12So I'm going to open the homepage in a new tab and let's visit it.
01:16Now, our site is starting to really come together.
01:19We see a lot of imagery that was not there before, and the reason these images
01:23now show is because our CSS already had these images declared, but the files
01:29just were not there.
01:30There are some things to fix, but remember, we're not done building this Drupal thing.
01:35One thing to point out about images is you can actually have subfolders inside
01:40an images folder, as you see necessary.
01:44Outside of the images folder, there will be a couple of graphics that usually
01:48appear in themes, like the logo, the screenshot and the fav icon.
01:55These are totally optional, but you can have them in either the images folder or outside of it.
02:01Whenever you actually want to declare a screenshot to be inside the images
02:06folder, you'll need to make sure that you put the images path.
02:10But since we don't have our screenshot in the images folder, that's not what we
02:14need for this theme.
02:16When working with images in CSS, as I'll show in the style.css file, you do not
02:22want to make absolute paths to the imagery. You want to use relative paths only.
02:29So as we see here on line 7, this background image for the body is
02:33calling images/bg.png.
02:37If you were to create an absolute path, which is a full URL, and the theme is
02:44moved or ported to another site, then the URL to the image is bound to break.
02:51By having images only a relative path, we now are making the Drupal theme
02:56much more portable.
02:58Separating theme graphics from the rest of the site is a wonderful feature of
03:02Drupal for both maintenance reasons and just plain web design sanity.
Collapse this transcript
Understanding theme templates (tpl.php)
00:01Up to this point, we have repaired our theme info file, custom style sheets and
00:05graphics. The remaining pieces for our flower shop theme are templates.
00:10In this video, I will go over which set of templates we will be building over
00:14the next few chapters.
00:16The three main Drupal templates everyone needs to learn are Page, Node and Block.
00:23Every Drupal page is made up of various templates, all merged together like a puzzle.
00:28We have the nodes and blocks that appear in regions surrounded by the Page template.
00:34Page templates get the HTML, head and body tags, while only node templates and
00:40blocks get content and layout tags like div and span.
00:44Page templates have a lot of HTML markup and PHP variables.
00:48The markup in PHP code in these templates can be moved around anywhere to
00:52customize the markup and its layout.
00:55No templates are used to control the content area's markup.
00:59Each node bases its markup of a standard node template file.
01:04Node templates do not contain head or body tags since those are the
01:07responsibility of page templates.
01:10Instead, node templates provide tags like div, and span, and sometimes
01:15heading tags like H1 or H2.
01:17Node templates also utilize PHP variables for the content.
01:22Block templates control the markup for all the secondary content, usually
01:27known as sidebar content.
01:29Blocks can be stacked in any theme region and have a standard template that's
01:33used for every block on the page.
01:35Block templates are similar to no templates, in that they do not also contain
01:39any of the HTML, head or body tags, but only layout and content tags like div,
01:46and span, or headings.
01:49Block templates also utilize PHP variables for their content.
01:53A theme can have many templates or none at all.
01:56Let's look at our design and see how that fits into the template scheme.
02:01So we see the flower shop design, and we can see immediately that the
02:06highlighted page is the entire page template, because, of course, this is the
02:11shell of the site, since it would be containing the HTML, head and body tags and
02:16of course,all the theme regions.
02:19In the main content region, will appear the nodes.
02:23The default homepage of Drupal renders multiple nodes on a screen.
02:27This would mean that the node template would be used for each node that
02:32appears on the screen.
02:33In this design example, we're only looking at a single node on the page.
02:37So the main content region only is going to use a single node template.
02:42The secondary content or blocks, as they're known, will appear in the sidebars
02:48and in our custom footer region, and Drupal will use the same standard block
02:54template for all of these blocks that appear on the page, unless we define some
02:59custom templates like we'll be doing in a later chapter.
03:03Throughout the rest of this course, we will be covering each set of theme
03:07templates in more detail while assembling them.
03:10The key to customizing Drupal's front end is being comfortable with the theme
03:14templates as they are the heart of every Drupal page.
Collapse this transcript
Understanding template variables
00:01As mentioned earlier, Drupal theme templates are composed mostly of HTML, mixed
00:05together with some basic PHP variables.
00:09Knowing what list of variables are available per template is very important for
00:13a designer to know, because that is a whole list of elements that you can design
00:18in your theme templates.
00:19A lot of the variables are not even used by most themes.
00:23This is a little bit unfortunate, because I think there's a lot of items that
00:27people are missing in their design, because they just probably don't know
00:31they're available to each template.
00:34There are two places we can find out the list of PHP variables available per template.
00:40The first place is the official Drupal API website available at api.drupal.org.
00:47In here, we can actually do a quick search for any template we wish to look up,
00:52and we can find the list of variables in that reference document.
00:56So I want to look up page.tpl.php.
01:00Now the API site has just returned some results, in fact, multiple results for page.tpl.php.
01:08We want to only look at the ones available in the modules folder within Drupal core.
01:13So this bottom link is the one we're going to click on.
01:16Now we see the list of variables available to just the page templates.
01:21So we see some good variables in here like is_front, and you'll notice PHP
01:27variables are always prefixed with the $ sign.
01:30This is how PHP knows what is a variable and what is not.
01:34So going back to this example, is_front is a Boolean variable, which contains a
01:40value of either True or False.
01:43When this is True, that means the current page we're viewing is the front page,
01:48otherwise it would be valued at False.
01:51The other place I want to show you where you can find these template variables
01:54are is actually in the template itself.
01:58So since we know where these templates reside, we can actually open them up
02:03in our text editor.
02:04So, then we go File > Open and I'm going to hunt for the
02:09modules/system/page.tpl.php file within drupal-6 core.
02:17So let's open that file and if we read the comments here at the very top,
02:22we see it is actually a whole list of all the variables available to this page
02:27template, and actually all page templates.
02:30So in here, look again.
02:32There is the is_front variable.
02:34So you can reference each template or you can reference the API website for
02:40Drupal to find these lists of variables.
02:43Templates and their variables are the first major hurdle in understanding
02:47Drupal theme design.
02:49Designers should be comfortable with how these pages are built from Drupal, so
02:53they can affect the theme layer anyway they wish.
Collapse this transcript
7. Page Templates
Understanding page templates
00:00The first set of Drupal theme templates we'll be covering are the Page templates.
00:04Every page Drupal renders uses a page template.
00:08In this video, we will review what makes a page template file so important.
00:12So the standard page template Drupal uses is a file called page.tpl.php.
00:19Now you don't have to create this file from scratch as the common Drupal theme
00:24workflow is you locate the standard templates in Drupal core, you duplicate them
00:30in your theme, and then modify it as needed.
00:33So let me show you where the standard page.tpl.php file lies.
00:38I'm going to open my drupal-6 folder, and we won't be visiting the themes
00:43folder. We will actually be going inside the modules folder.
00:48Inside the modules folder, there is a system folder.
00:53We see there is a page.tpl.php file.
00:57In Windows Vista, it's automatically hiding the file extension, so don't be
01:02tricked by what Windows is showing on the screen. The file is actually .tpl.php.
01:09So let's actually look at this file in Dreamweaver.
01:12I'm going to edit with Dreamweaver, but we won't be saving this file or changing it.
01:17I just want to show you what's inside of a page template.
01:21In the next video, we would actually be duplicating the page template into our
01:25own theme and editing it.
01:28So let's see what makes up a page template.
01:30First off, as mentioned earlier, there are a bunch of template variables.
01:35All of these variables are usually specific to the single template that they appear in.
01:40So a couple of these, I want to just highlight, because we're going to see them
01:44inside of our markup.
01:45There will be the CSS variable.
01:49There is going to be the body_classes variable and, of course, definitely, the
01:56site_name and logo variables.
01:59A couple of key ones that our flower shop will end up using later is the
02:03search_box variable, and we get to the regions that are very important,
02:09because this is where all our content ends up being injected into, which is
02:13left, content and right.
02:17So let's scroll down to the actual markup used by the Drupal page template.
02:22So we see past the comments around line 78, we see the standard markup for an HTML page.
02:31We see tons of PHP variables sprinkled throughout this page.
02:37So we see here a couple of the variables that I've mentioned above, which are
02:41body_classes, logo, and site_name.
02:45Around many of these variables are actual HTML markup.
02:50So this page is literally the standard page that will be used for every Drupal
02:57page of your site, because we would need the HTML header code and of course
03:03we need a body tag.
03:06What the PHP variables do here is actually replace this PHP line with actual content.
03:15Don't confuse the content right now with the node content, because styles,
03:21scripts and all the other headings are sometimes considered part of the content.
03:29Normally, an HTML page would have meta tags in the head, but that's not the case
03:34with a Drupal page template.
03:36Instead, Drupal only requires a PHP variable to print on the page known as head
03:42and all the things like meta tags will automatically be compiled into this one
03:48variable known as head and placed on this line.
03:53That is why there is a styles and scripts variable in this template within the HTML head tag.
03:59This is for all our style sheets and all the JavaScript needed for our website.
04:06We would not declare any styles or scripts in this file, because Drupal will
04:10actually grab that information from our theme.info file and place that code here
04:16automatically for us.
04:18So let's move past the body tag and get into the actual markup of the page.
04:23So we see we have a standard div tag with an ID known as page, and it actually
04:28has a header div inside of it.
04:31In here, we break down the logo, the site-name, anything we need.
04:36Actually, the site-name is wrapped in an h1 tag.
04:39This is actually good semantics for a website.
04:42So scrolling past the header div, we see there is the search box, which our
04:49theme will be using later on for the flower shop.
04:52If we go down a little further, we get to an area called container, which
04:57holds the navigation div.
04:59Now the navigation div is where the primary menu and the secondary menu appear.
05:05So here is the markup for both the primary and the secondary menus.
05:11Scrolling past the navigation header, we get now to one of the most popular regions,
05:17which is the left sidebar.
05:19So we see here that there is some logic that wraps the markup used for the sidebar left.
05:26This logic is PHP code and it's very simple code, but you need to understand
05:32what it's saying here.
05:33So it actually is defining that if there is no empty content within this left
05:41template variable, then go ahead and spit out the markup to the page.
05:48So we see this print function call for left will actually enter the content here,
05:54but only when we satisfy this conditional logic.
05:58This is actually how Drupal and PHP pull out an entire region when there are no
06:05blocks or content to render there.
06:07That's how you magically go from a two- column layout to a three-column layout in Drupal.
06:14Now one of the most important regions is the content region and that is
06:19surrounded by a div with an ID of content.
06:22In here we have the print content variable, and this content variable is
06:28actually where the main primary content goes, which is your node templates.
06:34So your node content would end up going through the node template, and then be
06:38prepared and then fully injected into this line.
06:42So if we go past this, we'll see that there is a right bar just like the left
06:47and of course, the footer_ message and the footer region.
06:51At the very bottom of the page is probably one of the most important regions to
06:56Drupal and not our content, known as the closure region.
07:00A closure region is required at the bottom of every page template.
07:05This region is used by Drupal and modules to render any unseen content at the
07:10very bottom of each page.
07:12You do not need to declare this region in your theme info file, but Drupal does
07:17expect it to appear in every page template.
07:21Common scripts like web analytics require their own JavaScript code to appear
07:26at the bottom of a page, so they can track users for you.
07:30This is a key reason why the closure region exists, to facilitate needs like this.
07:36What we will be doing for our page template is taking this code and modifying it
07:42by adding regions or changing some of the markup.
07:46Drupal is not limited to a single-page template.
07:49Custom page templates can be created for the front page or the site maintenance page.
07:55Each of these templates can change the entire layout and all of these templates
08:00are actually covered in this chapter.
Collapse this transcript
Creating a template to theme every page (page.tpl.php)
00:00The first important template to learn is the page template, otherwise known as page.tpl.php.
00:08This is the template used for every page that Drupal renders.
00:11It is a very important template as it lays the page structure and has all the
00:16placeholders for the content areas, known as regions.
00:20In this video, I'll be copying the page template file from Drupal core into our
00:25theme folder and modifying it for our flower site.
00:29So, the page.tpl.php file is actually located in Drupal's modules/system folder.
00:40Here it is page.tpl.php.
00:43Now don't be fooled by Windows Vista, because this template file is not .tpl.
00:49It is actually .tpl.php.
00:52We just don't see the full file extension.
00:55You want to actually right-click, copy this file, go to your theme folder
01:01hanselandpetal in sites/all/themes/ hanselandpetal, and actually paste this file.
01:09Let's go ahead and open this file in Dreamweaver or your favorite text editor
01:14and we'll be actually modifying this file.
01:16So, the first thing we should actually edit since this will be our modified
01:20version is to remove the line of code that says who originally authored this
01:25template in Drupal core. So, delete line-2.
01:28Now, let's go down to around line 120.
01:35Here is actually the end area of the header div.
01:39The first edit we would want to make in our version of this page template file
01:44is to move the navigation div, which holds the primary and secondary links.
01:51We want to move that navigation div from the container div into the header div.
01:59Let's go to our site as it is now to see what I'm talking about.
02:03So, I'm going to open a new tab to the homepage and we're going to inspect this
02:09page with Firebug, which is an extension for Firefox.
02:14I'm going to quickly highlight the navigation area as it's being rendered in the
02:19standard page template right now.
02:21As we see this is not where the navigation area was originally designed to be
02:25but instead of in the brown band area.
02:28Well, the reason for this is the standard page template that is being picked up by
02:34Drupal core has its navigation div highlighted here inside the container div,
02:40and like I was saying before, we want to move this div into the header div and
02:46outside of the container div.
02:48So let's go and do that now in our text editor.
02:51So, I'm going close Firebug for now, open my text editor, Dreamweaver, and
02:56I'm actually going to scroll down and highlight lines 127 to 139 and in Dreamweaver,
03:05I'm able to actually just drag-and- move where I want the code to be.
03:10If you can't drag your code, you'll need to cut-and-paste the navigation
03:15div into this new area.
03:17So, I'm going now click Save, go back to my Drupal theme administration page,
03:23and we need to flush the theme cache, so we'll click Refresh and we'll go back
03:28to the tab that has our homepage and we'll then refresh that page as well.
03:33So, we see no change.
03:35That means Drupal didn't pick up our new page template.
03:38So, let's go back to the theme administration and let's click Save
03:42configuration. This will kind of push Drupal to make sure that it does
03:46register our changes.
03:48Let's go back to the homepage tab and click Refresh.
03:52Now we see that a big change has happened.
03:55Let's inspect this markup with Firebug and we now see that the navigation div is
04:01properly inside the header div as our designer expected it to be.
04:07There is one more addition we need to make to this page template file right now.
04:10So, I'm going to close Firebug and I'm actually going to pull some code I've
04:15already prepared in the Chapter 07 folder.
04:19This code is in a text file called new_page_regions.txt.
04:26So, I'm going to edit this file in Dreamweaver.
04:29You will need to copy and paste the content of this text file into
04:34your page.tpl.php file.
04:38If you are not a premimium member of lynda.com, you do not have access to
04:42the Exercise Files.
04:44Since this file is essential to completing this project, we've included it as
04:48a free exercise file.
04:50You can download this file from the course page. And as you see it's some PHP code.
04:56Well this PHP code defines new regions for our page template.
05:03We've already defined these regions in our theme.info file.
05:07So, let me show you that now.
05:08So, I'm opening hanselandpetal.info and these are the three regions I'm talking about,
05:14Footer Content 1, 2 and 3.
05:18So, I'm going to go back to the text file. I'm going to select all. Copy.
05:24I'm going to go our page template file.
05:26Now I'm going to scroll near the bottom and right after the line 170, which is
05:34the end of the container div,
05:36and right before the footer wrapper div, I'm going to add a couple of new extra
05:40lines and then I'm going to paste the new code in.
05:44I'm going to add a little white space and this is the new code that will
05:49actually output the markup for the new regions that were defined.
05:53Remember, these are the region ids that we declared in the .info file.
05:58So going back to the page template, our code looks good, I want to save, and now
06:03we want to go back to our Drupal site and we can just click Refresh because
06:09Drupal already knows about this page template, so any changes that we've done
06:13inside of it will be picked up easily.
06:15So, I click Refresh and now we scroll down to the bottom to see our new regions added.
06:21In fact here's the three regions.
06:24So they make three new columns inside this brown area near the footer and the
06:28blocks that actually have been placed there earlier now show up.
06:32We also see that the columns have equal heights and that's a result of the
06:38JavaScript files we added in the previous chapter.
06:42Every theme usually gets its own page template as it is responsible for
06:46arranging a site's page structure.
06:49Any other page template covered in this chapter will be derived from this template.
Collapse this transcript
Creating a template to theme just the front page (page-front.tpl.php)
00:00As mentioned before, a Drupal theme can have a special page template just
00:04for the front homepage.
00:06In this video, I will introduce the custom page front template for Drupal themes.
00:12The front page template is derived from the standard page template we've already
00:16created in our theme.
00:18The only difference here is the file name will be page-front and of course any
00:23edits we wish to make inside the file.
00:25So let's prepare this file now.
00:28I'm going to open my theme folder hanselandpetal that's inside my
00:32sites/all/themes folder and we already have the page.tpl.php file.
00:39So I'm just going to actually copy-and-paste.
00:45So we'll rename this new copy to page-front.tpl.php.
00:55So let's actually edit this in Dreamweaver.
00:58So it's exactly the same as our page.tpl.php.
01:04What I would like to do to the front template is actually remove the new footer
01:09regions that we added.
01:11The reason being the homepage has a lot of text that you scroll down through and
01:17the bottom area is hardly ever seen.
01:20So this region makes much better sense to appear on the other inner pages of the website.
01:26So let's go back to Dreamweaver.
01:28Let's scroll down in page-front to the new footer content regions that are on
01:35lines 172 to lines 195.
01:39We're just simply going to delete these regions and save our file.
01:43So let's go back to Drupal and we need to actually let Drupal know that there's
01:48been a change in our theme folder.
01:51So the first way we do that is we actually refresh the theme page, go back to
01:57our theme, and since we have a new front page template, we'll be refreshing the
02:03homepage of our Drupal theme site.
02:06We see now with the refresh that those regions have disappeared.
02:11Let's click on one of the inner pages and let's scroll down and we now see that
02:17the regions are respected for every other page that is not the front page.
02:23We see the regions there and if we go back to Home, let's scroll down and
02:27those regions are gone.
02:29One additional change I would like to see is the reduction of the double search box.
02:37I like the search box up in the header for the homepage but I don't want it
02:41on every other page.
02:43So I won't be editing the page front template, but I'll be going back to the
02:48standard page template and looking for the search box variable and that's
02:54actually up in around line 113.
02:55I'm going to delete this set of code.
03:00I'm going to save page template and now I'm going to go back to our Drupal site
03:05and I'm going to refresh the homepage.
03:08We don't see a change here because this search block needs a configuration set
03:13in the blocks administration screen, so it doesn't show up on the homepage, but
03:18if we visit any of the inner pages now, we see that the header disappears
03:23because the code for the global search box in the header is now only in our
03:28page-front template.
03:31Let's quickly set up to search box to only show up on the inner pages.
03:36I'm going to do that through the Blocks administration.
03:38So I'm going to go back to my Drupal administration screen, I'm going to open Blocks,
03:42I'm going to scroll down, I'm going to find the Search form block, and
03:47I'm going to click Configure.
03:50In here, we go down and I'm going to click Show on every page except the
03:55listed pages and the listed page that we don't want this block to show is the front page.
04:00I'm going to click Save blocks, go back to our drupal-themes site, I'm going to
04:06click Refresh and of course the search box should stay on this page since we're
04:12on the Services page.
04:14Let's go back to the home and now we see the search block does not appear in
04:19the sidebar for the homepage but we do get the global search up on top.
04:24Having a custom front page template could be a great way to set your theme apart
04:29from other Drupal themes that do not use this feature.
Collapse this transcript
Creating a template to theme individual pages (page-node-nid.tpl.php)
00:00Up to this point we've seen how every page relies on the standard page template
00:04and how the front page can have its own template.
00:08Now it's time to show you how to create a page template for a specific node
00:13different from the rest of the site.
00:15So for this exercise, we actually will be going through and picking one of
00:19the nodes already saved in the site and targeting it to have a specific page template.
00:26Now what we're doing here is we're not creating anything with the node templates
00:30yet as that's in the next chapter.
00:32For this video, we're actually just altering the surrounding page template that
00:38would be used on a specific node's page.
00:42So let's actually load up a node that is a page type, and I'm going to
00:48choose this Services node.
00:50There is a naming convention needed for this template, which is very similar to
00:55the other two page templates we've already created.
00:59The naming convention for this template is page-node- and then the node id.
01:08We need to get the node id through the Drupal Administration interface, so we
01:12can actually copy that id and then use it in the templates filename.
01:16To do that we can click Edit on the node we wish to target and reference the URL
01:24because the id of the node is actually in the URL.
01:28So we see that this node's id is id number 5.
01:32So we're going to go to our theme folder and we're going to actually copy and
01:39paste our standard page template file and rename it page-node-5 because that's
01:52the node id of the services page.
01:55So now let's edit this file in Dreamweaver and since it's like all the other
02:00standard page templates we've been building so far, we can just scroll down and
02:05edit the area we wish to remove or add.
02:09For this page, I wish to have the sidebars not appear at all and while this
02:16might be a scary proposition for this single page, we can always get to the
02:20sidebars in any of the other pages, since the template will only be used on this node page.
02:28So let's go back to our text editor, we're going to go through and find the left
02:34and right sidebars and remove them.
02:37So I've just removed the left sidebar and I'm now removing the right sidebar.
02:43We're going to save this page-node-5 template, we're going to minimize our text editor,
02:49and we're going to go back to our theme administration page, we're going
02:54to click Refresh, so Drupal updates its information about your theme. Then we go
03:00back to our Services node page, and we're going to click Refresh.
03:06Now we see that the sidebars have been removed, but only for this page, because
03:12if we click around we see that the sidebars appear properly all across the rest
03:18of the site except for this one node page.
03:22This template does not modify how the content of the node is displayed as
03:26that is done through the node templates, which are covered in the next chapter of course.
03:30I do not recommend making separate page templates for every node in your site,
03:36but when a big change is needed for a single node page then this template is what you should use.
Collapse this transcript
Creating a template for "site offline" maintenance pages
00:00When a Drupal site is offline, also known as maintenance mode, then none of the
00:05site's content appears except a simple custom message usually saying the site is offline.
00:11By default this page renders with the blue Drupal screen.
00:14But we can control how this page looks within our theme.
00:18In this video, I will show you how to configure a Drupal site to use a custom
00:22maintenance page template.
00:24So, before we make the maintenance page template, I want to show you a reference
00:28URL that is in the Drupal theme guide.
00:31This is all the information you need to know about custom maintenance pages.
00:36In this video, we'll be creating a standard maintenance page template.
00:40So, going back to our Drupal site, we need to actually open up the Site
00:46Maintenance Administration screen.
00:49And that's in the Administer > Site maintenance.
00:53On this page, we can put our site into offline mode, locking everybody out who
00:58is not an administrator.
01:01Here is the custom message that's going to appear for the site offline page.
01:06Before we turn our site offline, let's go and view the site in another browser
01:11that's already locked out.
01:12I'll be using Internet Explorer for that.
01:15So, I have Internet Explorer ready and as we could see everything is rendering
01:20as expected and if we turn the site into offline mode now, we are going to
01:25see a big difference.
01:27So, let's go back to my Firefox. I am going to turn the site into offline mode.
01:32Click Save configuration.
01:34Now, I am going to go back to Internet Explorer and I'll click Refresh on the
01:38Homepage of our flower shop.
01:40Now we see a maintenance page that looks nothing like our site.
01:45Imagine if you had to turn the site offline to do an update and your
01:50customers came back and kept seeing this blue page, they might think they're
01:54actually at the wrong site.
01:56We don't want that to happen to our customers of the flower shop.
02:01So, let's create a custom maintenance page, so it can look just like every other
02:05page that we have in our theme.
02:07A maintenance page is a little bit more complex than the other page templates in
02:12how it's actually set up because we require two files to be edited here.
02:18The first is the maintenance page template.
02:20Let's create that first.
02:22So, I am going to minimize Internet Explorer.
02:23I am going to open my hanselandpetal theme folder.
02:28And just like the other page templates, we are going to duplicate
02:33page.tpl.php and rename it.
02:37So, let's copy and paste and rename this file to be maintenance-page.tpl.php.
02:53And we can edit this file in Dreamweaver, but right now that's not necessary.
02:58Instead, we need to edit the one file that controls the settings for our site.
03:05And the reason why is because Drupal needs to know and have the theme that will
03:11be the maintenance theme hardcoded, because it can't depend on the database to
03:16let it know what theme is active, since the site is in offline mode.
03:20So now that I setup this template file, I am going to open my settings.php file for my site.
03:28And that's located for me in my drupal/ sites/lynda-drupal-themes folder and here
03:34is the settings PHP file.
03:36I am going to show the properties of this file and point out that this file is
03:41always marked as Read-only.
03:43For this exercise, we have to uncheck this and make this file writable.
03:50If you're following along on a Mac, changing the files permissions is done
03:54differently than it is on Windows.
03:55Let me show you how to do that on Mac.
03:58So, I am going to visit my drupal/sites/lynda-themes-folder.
03:59And I am going to right- click on my settings.php file.
04:07If you don't have a right-click button, you will use Ctrl+Click.
04:11Choose Get info and we'll have to actually adjust the window to show the little
04:17lock in the bottom-right corner of this file info window.
04:21So we'll click the lock, we will type in our administrator Password to unlock
04:26this window and we'll change the Read only setting to Read & Write.
04:31Then you can click the lock back.
04:34Close the Info window and continue.
04:36I am going to open this in Dreamweaver and then we need to scroll down to find
04:42the configuration array and uncomment a few lines and then edit one of them to
04:48actually mark our theme as the maintenance theme.
04:51So, I will do that here.
04:53The first line in my settings file is the conf = array line, so to uncomment
05:00this line, you want to remove the hash mark that's in the front.
05:04The other line we need to uncomment is the maintenance_theme line that is below
05:10the conf array line.
05:12And actually right here we see minnelli has been set as the default maintenance theme.
05:18If we go back to Internet Explorer, we can confirm that by looking at the blue page.
05:23So, minimizing Internet Explorer, we go back to our text editor and there's
05:27one more line that's important and we need to uncomment and that is the end of
05:32the array declaration.
05:34So, you make sure that you uncomment this line that has a closing
05:39parenthesis and a semicolon.
05:43Now, we go back up to the maintenance_ theme line in our settings file and change
05:48this minnelli value to our theme ID.
05:52If you don't remember what our theme ID is, you can go back to the
05:56hanselandpetal them that we've been building and get the theme ID from the .info file name.
06:02So, it's hanselandpetal, so let's copy this name, go back to our settings.php
06:09file and paste in our theme ID.
06:13We are going to now save this file.
06:15We are going to go back to our site folder to turn on Read-only again.
06:21So, I am going to choose Read-only only, OK.
06:25Now, I am going to go back to Internet Explorer where we see the blue page we don't want.
06:30Now, I am going to click Refresh.
06:33I click Refresh and now we see our hanselandpetal theme up here for the
06:38site offline mode.
06:40Before we go, I want to make sure that my site is not left in offline mode.
06:44So, let's go back to our theme administration in the other browser and let's
06:49click Online, Save configuration.
06:52We can now go back to our Internet Explorer, refresh and we should see our site
06:57in online mode again.
06:58Since creating a maintenance template takes a little bit of customization of the
07:03actual Drupal site, this might be a little bit of a scary proposition for some.
07:08So, I ask that you be careful when you are testing this.
07:12By adding a maintenance page template, we can still present a custom look and
07:16feel to our site's experience even when the site is in offline mode.
Collapse this transcript
8. Node Content Templates
Understanding node templates
00:00Node templates define how primary content should be wrapped in markup.
00:04In this video, we will review what variables are available to every node template.
00:09So, the node template is similar to the page template in that it's already
00:13provided in Drupal core and our site is already using it, but we want our own
00:19custom version of that template to reside in our theme folder.
00:23So let's go grab a copy of the node base template, which is available in
00:28Drupal's modules/node folder and the file is node.tpl.php.
00:36So, let's copy this file, we'll minimize the drupal folder and go back to
00:41our theme hanselandpetal located in sites/all/themes and we'll paste the
00:48node template file here.
00:50Now that we have our copy of this node template file, let's go ahead and edit
00:54it in our text editor.
00:56Just like all the other templates before, we need to remove the information of
01:02who authored this template for Drupal, because we are going to be modifying this,
01:06so we don't need that information up there.
01:10Just like the other templates we've seen before, there are some variables that
01:14we can use throughout this whole template.
01:16Of course, these variables cannot actually exist outside of this template.
01:21These variables are only for the node templates.
01:25So, we see things like title and content.
01:28These are used for actually the node title and the body content.
01:33Let's see where these variables exist within the code of the node template.
01:37We see here that actually on line 56 wrapped in a heading tag that the node
01:44title is printed and we also see on line 70 that this is where the node
01:50content body will go.
01:52Let's see where those actually render now on our site.
01:56So, going back to our hanselandpetal site, we see the Homepage has a few nodes here.
02:03We see some blog nodes and some flower nodes.
02:07The title of the node appears at the top and the content appears right under the title itself.
02:15If we were to visit a single node page, say service, we also see the same
02:21outline, which is title on top and the content on the bottom.
02:26Going back to the Homepage, we want to actually create our own custom version
02:32of this node template, so we have a different look than what is already printed on the page.
02:39It's a good idea to review what template variables are available during the
02:42design phase of a site.
02:44Going back to the node template in our text editor, I would like to bring up a
02:49couple of points here.
02:50First, you'll notice that a node template does not have any site shell markup,
02:55which is like the HTML tag, the head tag or the body tag.
03:01As we mentioned earlier, the node template is only for the content area.
03:06That's why the node template starts with a div tag and ends with just a div tag.
03:13There are no other required tags to go into this template unless they
03:17are content or layout.
03:19One more point, line 51 of this template actually shows that there are CSS
03:25classes and ids applied dynamically to each node template.
03:30We see that the id of this div will be called node- node id.
03:38So, if our node id is node id five, when this template is used for that fifth node,
03:45the id would be node-five.
03:49We see that there are some CSS classes here and class node is used with addition
03:55to a couple of optional classes that Drupal will put in when necessary, like
04:01node-unpublished and sticky.
04:04These have predefined styles in Drupal core, so you don't have to come up with
04:09these styles on your own unless you would like to.
04:13It is a good idea to review what template variables are available during the
04:17design phase, since the site can actually incorporate more elements than the
04:22standard template provides.
Collapse this transcript
Creating a template to theme every node (node.tpl.php)
00:00In this video we're going to edit our new node template that's inside our Theme
00:04folder, we're going to add some markup and a PHP variable available to node
00:09templates that is currently not there.
00:12So, let's edit our node.tpl.php file and we'll actually scroll to the variable
00:20list that says node_url.
00:24This is the variable that I want to use in my custom template.
00:28What I plan to create is a little link that will actually point to this
00:33node directly that people can use to take and share with other people known as a Share link.
00:39So, what I want to do here is actually add right under the content div,
00:46around line 73, I'm going to add an HTML link and the href is going to equal
00:55the php variable node_url.
01:00Remember you have to have the print in front of URL for Drupal to know that it's
01:05going to actually print out the value to the screen.
01:08So, let's close this </a> tag for the link text we're going to say "share this."
01:15Let's click Save and we need to go to our Drupal theme administration page
01:21to refresh the theme cache, so we could pick up our new node template within our Theme folder.
01:27Now let's go back to our hanselandpetal Homepage and let's click Refresh to see
01:33our changes in the node templates take effect.
01:36Now, we have a very simple 'share this' link, pointing directly to the node.
01:42This actually will appear now in every single node on the website.
01:48So, let's scroll up and let's look at the services page and at the bottom,
01:53there's a share link and of course, at the bottom of the about us page is also a share link.
01:59While the flowers and blog posts make sense to share, these two inner pages
02:05about us and services, do not make sense to share.
02:09So, in the next movie, we will create a node template for page types that do not
02:14have the share link.
Collapse this transcript
Creating a template to theme custom node types (node-type.tpl.php)
00:00Each node type in Drupal can have their own modified node templates.
00:04With our base node template file prepared, we can make derivatives of this
00:08template for each content type our site has.
00:11In this video, we will duplicate the base node template for each content type in
00:16our Flower site, allowing each node type to get a custom look and feel.
00:20So, as you might have guessed, there is a naming convention involved with
00:25duplicating a base node template for each content type and that naming
00:30convention is actually node-type.tpl.php.
00:36But we need to find out how we get the type, so we can actually create the file names.
00:41And to do that let's go to our Drupal website and in the Administration section
00:46let's go to Administer > Content types and here we see a column called Type and
00:54this is the machine ID as it's known in Drupal for each Content type.
01:00So if we're to create a node template for blog, we would end up making a file
01:06called node-blog.tpl.php and for flower, we would make a file named
01:15node-flower.tpl.php.
01:19So, let's actually do that now.
01:20I'm going to minimize my browser and open up my hanselandpetal theme, which is
01:27in the sites/all/themes folder.
01:30Now, I'm actually going to copy and paste the node template file.
01:35Now, I'm going to rename that copy to node-blog.tpl.php and let's make another
01:44copy for our flowers and rename this file to node-flower and let's make one
01:54final node type template for just the page types.
01:58So, let's copy the node template and paste and then we'll rename this copy
02:04to node-page.tpl.php.
02:10So, now that we have our node type templates, let's go ahead select these and
02:16edit them in our text editor.
02:19I'm using Dreamweaver, and as I mentioned in the previous video, the page types
02:25end up getting a share link that we added to all the node types through the
02:30standard node template file.
02:33Let me show you that link now.
02:34So, I'm clicking the services. I scroll down and there is a 'share this' link.
02:39Well, we don't want this 'share this' link to appear on the node page templates, so
02:45let's edit that file to remove the line of code that actually declares the share this link.
02:52In my node page template, the line that I wish to remove is line 73.
02:57So, I want to delete this line and some extra white space and now I'm going to click Save.
03:03For the flower node template, I actually want to add the word flower in the
03:08front of every title that comes out, because these are product pages for the
03:12website, so I would like these to be a little bit different in that way.
03:16So, I'm going to actually hardcode the word Flower with a colon and a space,
03:23in front of the printed title.
03:25So, now that we have these different node type templates, we can actually now
03:29go back to Drupal, and go to the Themes administration screen under Administer
03:36> Themes and since we loaded this page, Drupal should have already cleared the theme cache.
03:43If you were already on this page, be sure to click Refresh so Drupal can look
03:48inside the hanselandpetal folder to find the new template we just created.
03:53Let's go back to our hanselandpetal pages.
03:57Since, I'm already on the services page, I'm going to just click Refresh and we
04:02see now the 'share this' code is no longer appearing on the services page.
04:08The same should be for the about us page type and we don't see a share this link.
04:14But if we go to the Homepage, we now see that the Flower node types have a
04:20prefix in the title that we entered into the Flower template and the share this link,
04:25of course, still appears because that is inside all the other templates
04:30that we created as well.
04:32Each template should follow the same structure as the base node template, using a
04:37heading tag for a title and div tags to wrap the content.
04:42One point to know about node templates is you cannot currently have a node type
04:48template like blog, flower, or page without its parent template node.tpl.php
04:56being in your theme.
04:57This is a current limitation of Drupal and might change in the future.
05:01Creating templates for each node type allows designers to customize the look for
05:06every piece of content in their Drupal site.
Collapse this transcript
Discovering node templates using the theme developer module
00:00Early in the chapter, we figured out what are node templates should be named
00:03using the Drupal administration.
00:05Now I will show you how to use the Theme developer module to expose what node
00:09templates can be made for our theme.
00:11So I'm going to head back over to the Drupal administration screen and I'm going
00:15to click on Modules.
00:16Now I'm going to enable the Theme developer module and the Devel module, since
00:22the Theme developer module needs it also enabled.
00:24I'm going to scroll down, click Save Configuration.
00:27Now I'm going to go back to my Drupal homepage and I'm going to click Refresh,
00:32so we can get the Themer info button appearing at the bottom-left corner.
00:36I'm going to check the Themer info and then we see now we have a floating dialog
00:42window that we can now use to highlight an area that is on the Drupal page, say
00:49this node, and get some information about it.
00:52In fact, since we're building node templates right now, we can actually click
00:56on these nodes and use this tool to see what candidate template files can be created.
01:02So of course, we already have a node template file and we see here that this
01:07tool recommends a node-flower template.
01:10We already created that template in the previous movie, but now we see that we
01:14could use this tool to actually click around our Drupal site and discover what
01:19templates we could be creating for our theme.
01:22We will be using the Theme developer module throughout the rest of this course
01:26to help us to discover what templates our theme can provide.
Collapse this transcript
9. Block Templates
Understanding block templates
00:00Blocks are the third important set of templates we'll be modifying for our
00:04custom flower theme.
00:05Block template variables are a bit different from both the node and page
00:09template variables we covered in previous chapters.
00:12In this video, I will show you how block templates are structured and how their
00:15variables are different from what we've learned before.
00:17So let's go and look at the standard block template that is already provided in Drupal core.
00:23So we'll open the drupal-6 folder and we're going to look at the block template
00:28file that's available in the modules/system folder.
00:32The file name is block.tpl.php.
00:36So let's view this in our text editor.
00:40We see that there is actually not too much code in this template and we see that
00:44there are variables available to us for block templates just like we've seen in
00:48node and page templates.
00:49Let me point out a couple of the important variables that we're going to see in
00:54a block template and actually how they're formatted differently from other
00:57variables that we've been seeing so far.
00:59First is the Block Title.
01:02This variable is actually block-> subject and we see that there is actually
01:08this kind of little almost arrow character that is in the middle between
01:12the words block and subject.
01:14You need to be sure that you copy the whole variable name starting from the
01:19dollar sign all the way to the end of the name when you're copying these.
01:23Because if you leave off any characters, then that's actually going to be an
01:26invalid variable and you won't see your text printed to the screen.
01:30The second important variable for block templates is the content variable.
01:35So we see that block-> content is actually going to be printing out the
01:39body content of a block.
01:41Now let's see where that happens in our Hansel and Petal site as it is now.
01:45So here's our flower shop.
01:48We see that there is the title or the subject of each block that's rendered and
01:53we also see that there is the content area rendering for each block.
01:57So let's go back to the block template.
02:00Now let's look at the markup that's involved here and we see just like in nodes,
02:04the templates for blocks start with a <div> tag.
02:08The ID of a block is provided by Drupal and we'll learn more about that in
02:13one of the next videos.
02:15We also see that every block gets a CSS class of block plus a dynamic class that
02:22is actually covered by modules.
02:23That will be also covering in one of the next videos.
02:27So here is the code that actually outputs the markup for the block subject
02:32or title of the block.
02:34We see that the conditional logic in PHP here is stating on line 30, that if
02:40the block has a subject then Drupal needs to print out this heading tag along
02:45with the subject text.
02:48And then of course, with the beginning of an IF statement is the end of the
02:51IF statement, line 32.
02:54This means that the subject is optional for blocks.
02:59What is not optional for blocks is the content markup.
03:03So we see that there is a div with a class of content and then we see that
03:07Drupal prints the blocks content.
03:11We can hit this content with CSS, just like we can hit the class of the
03:16entire block with CSS.
03:19Throughout this chapter, we'll be seeing the block variables used in all
03:23our block templates.
03:24So be mindful of how these variables are formatted differently from other
03:28template variables that were covered in the course.
Collapse this transcript
Creating a template to theme every block (block.tpl.php)
00:00In Drupal, we know that secondary content appear in what are known as blocks,
00:05located in the left and right sidebar as we see on the screen.
00:09In this video, I will show how to include a block template that will be used for
00:13every block in our theme.
00:14So I'm going to minimize Drupal and I want to open up the Drupal folder and
00:20I need to locate and copy the block template out of Drupal core, to include it
00:24in our Theme folder.
00:26So the block template is in modules/ system, and the file name is block.tpl.php.
00:36We're going to copy this file, minimize the Drupal folder, go to our
00:41hanselandpetal theme located inside of the sites/all/themes, and we're going to
00:46paste the block template.
00:49Let's go ahead and modify this file.
00:53Since we are now going to include this block template into our own theme,
00:57the first thing we need to do is always remove the previous author's information,
01:02since our theme now has its own version of the block template.
01:06Scrolling down, we see that the markup for a block is very minimal. In fact,
01:10just one heading tag and one div tag for the content.
01:14I want to add a new class to the heading that's going to appear on
01:18every standard block.
01:19I want to click on line 31 and inside the h2 tag, I want to add a new class of title.
01:27Now, I can actually create a specific CSS class called title for h2 tags.
01:35So now that we've modified this template, we can actually go back to our Drupal page.
01:39We need to refresh the theme cache of Drupal.
01:43By doing that, we can visit the Themes Administration screen.
01:46If you're already here, just go ahead and click Refresh on the screen to let
01:50Drupal know that you've made a change to one of your themes.
01:54Going back to the homepage tab that we already have for our flower shop,
01:58I want to show you that right now, before I refresh the page, that the current
02:03titles for blocks, this h2 tag I have highlighted here, does not have the
02:07title attribute yet.
02:09I'm going to now click Refresh and I'm going to inspect that title again and
02:14we see now that our custom class of title is appearing on this block's heading.
02:19Let's check the other block and we see that the same is happening there as well.
02:26Block templates are the easiest to learn, since they have the least amount of
02:29code to read and modify.
02:31Every block template we create in this chapter and for our theme will be based off of this template.
Collapse this transcript
Creating a template to theme an individual block (block-module-delta.tpl.php)
00:00We know that each block uses a standard block template, but I'm sure you're
00:04wondering if individual blocks can have their own templates as well.
00:07When CSS alone cannot customize the look of a block for you, creating a specific
00:12block template is the next logical step when theming Drupal.
00:16In this video, I will create a new template that will control the look of a
00:20specific block on our page.
00:22In fact, the block I wish to customize does not yet exist in our Drupal site.
00:27I want to create a new Advertisers block that appears in one of the new footer
00:31regions that we have in our page template.
00:34So I'm going to click on one of the flower product pages and scroll down to show
00:38you the region I like the advertisement to appear in.
00:40I want the Ad block to appear in the center footer region, showing the
00:44Drupal icon right now.
00:46So I need to create this block and its content before we can customize a template for it.
00:51So let's go back to the Drupal Administration screen and let's upload the
00:56advertisement into a node, and then we'll call that Ad graphic inside of a block.
01:02To do that, we need to create content, and I'm just going to actually create a
01:07page for this advertisement.
01:09So I'm just going to call this node Ads, and I'm going to shrink the body text area,
01:15so I can get to the File attachments form. I'm going to browse for my
01:20advertisement graphic that is inside the Exercise Files folder of chapter 9.
01:26If you do not have the exercise files, you can upload any graphic that you wish
01:30to use as an advertisement.
01:31So let me go to my Desktop > Exercise Files. In Chapter 9, there is a
01:37graphic called gotdrupal.
01:39Let's upload this graphic by clicking Attach.
01:43We can leave it listed, because this page is not going to actually be viewed by
01:47anybody else except for the system administrators.
01:51I do want to copy the link to the graphic, because I'll be using this inside
01:56of the block content.
01:57So I'm going to click Save and now we're looking at the page we just created.
02:04You may be wondering, how do we go from the administration theme to our
02:08hanselandpetal theme?
02:09Well, we technically created a new node and now we're viewing that node.
02:14So, of course Drupal is going to use our front end theme and not the
02:17administration theme.
02:19Once we click Edit or click on Administer, we will be taken back to the
02:24administration theme known as Garland.
02:27So now that we have our advertisement graphic uploaded into a node, we can
02:31now copy the link to the graphic, and then create a new block using that graphic content.
02:37So I'm going to go back to the administration screen, I want to click on Blocks,
02:42now I'm going to add block, and I want to create an image tag inside the block
02:49body using the source URL of the advertisement.
02:55Now we only need, of course, the relative path for this image.
03:00I need to shrink the Block body text area, open the Input format field and
03:07choose Full HTML, so that this block renders the image tag.
03:12We have to give a block description first, so we'll put Ads and for title, we're
03:16going to put in the keyword of none for Drupal to not output any title for these
03:21advertisement blocks.
03:22I want to scroll down and we're going to just click Save block, and now we have
03:27an Ads block that we can position inside footer content too.
03:32So the Ads block will appear in here.
03:35Click Save blocks, and now if we scroll down, we can get a preview of that Ad.
03:40Remember the graphic was saved in the node and we took the URL of the graphic
03:46uploaded into our Drupal site and use that as the body content of this block.
03:51So, now that we have this custom block uploaded, let's customize it so we can
03:56show people that what they're looking at is a true advertisement.
04:00To do this, I would actually want to create a specific template that will target
04:05just this one block.
04:06Let's actually visit the homepage of our hanselandpetal site.
04:12I want to click on the flowers page and scroll down.
04:15I came to this page because I didn't need any the block's administration
04:18highlights getting in the way of what we're going to try to do next.
04:22What we need to do is open up the Theme Developer module, so we can click on
04:28this advertisement and reveal what block template we should be creating in our Drupal theme.
04:35So since I don't have the Theme Developer module enabled, I need to go turn that
04:39on and come back to this page.
04:41So I'm going to open in another tab the Administration window.
04:45We're going to click on Modules, go down to the Theme developer module, click
04:51Enabled, and also we'll enable the Devel module, since that's required as well.
04:56Click Save configuration, and now we can go back to our Sunflower page,
05:01click Refresh, and we now get the Themer info option.
05:05We'll click this to enable the window and we'll click on the block for our advertisement.
05:12We now see that there's some contextual information that this pop-up is revealing.
05:16It's providing some candidate template files for us.
05:20So we can create a block template file or any of these other templates for
05:25blocks that it's recommending to target this specific block.
05:31So the first thing we can create is a block-block-1 template, and that would
05:37actually target this one specific block, so let's do that.
05:40So I want to actually go down to my theme folder and we need to duplicate
05:46this block template.
05:47So let's click Copy, and Paste, and now we need to give the file name of
05:54this block template the same matching filename recommended by the Theme developer module.
06:00So let's edit the file name and we'll change it to be block-block-1.tpl.php.
06:11Let's go ahead and edit this template with our text editor and make the change
06:16that we want to appear on just this one block.
06:20So what I would like to add is a class to the list already there for blocks,
06:27a class of Ads, and I want to add a new heading tag right above where the
06:33subject would appear.
06:34This heading would be using an h6 tag, and I want it to say ADVERTISEMENT.
06:40We're going to close the tag and since I don't want the title of the block to
06:46appear when it's using this Ad block template, I'm going to remove that
06:50subject line code just in case somebody accidentally gives a false title to an advertisement.
06:56So, I'm going to click Save on this template.
07:00We're going to go back to Drupal.
07:01So we're going to go back to the Drupal Administration screen and click on
07:06Themes, so when the Themes Administration screen loads, it would actually update
07:10Drupal's internal cache about what templates are in our theme folder.
07:15So now let's go back to our Sunflower site, let's disable the Themer module and
07:21let's refresh the page.
07:23We see that something moved and in fact, if I highlight, the word ADVERTISEMENT
07:28is there just as expected.
07:30But the text is so dark we can't see it on the brown background.
07:35So let's add a new style in our style. css file, inside our hanselandpetal theme.
07:42We're going to open style.css and we're going to scroll down to the bottom
07:47and add a new style.
07:49So this will be ads h6 to get the heading tag in there, and we're going to give
07:55this a color of white.
08:02We're going to click Save on style.css.
08:05We're going to minimize our text editor and now we'll click Refresh.
08:09Now we see that our ADVERTISEMENT line appears above the Ad block, just as expected.
08:16Technically, there's no problem with creating a template for each block and
08:20any block you don't customize will still get the standard block template,
08:24which is just fine.
Collapse this transcript
Creating a template to theme all blocks from a single module (block-module.tpl.php)
00:00Drupal themes can contain templates for all blocks or individual blocks.
00:05Another feature of Drupal templates is the ability to theme all blocks that come
00:10from a single module.
00:12For example in Drupal core, the user module provides four blocks:
00:16the navigation and user login blocks, which are here on the left sidebar, and
00:22the who's online and who's new blocks we have in this footer content 1 region.
00:28In this video, I will show how to affect all these blocks from a single template.
00:34Instead of repeating templates for each block that belong to the same module,
00:38we can actually just duplicate the standard block template and rename it,
00:43so we would actually affect all the blocks from a specific module.
00:48We can use the Theme developer module to get a preview of what this block should
00:52be named, so let's go and do that.
00:54I'm going to open up my Firefox, I'm going to visit my Hansel and Petal site and
00:59I'm going to activate my Theme developer module.
01:02Now I'm going to go ahead and click on this navigation module.
01:07We see here that there is the candidate template files, block template,
01:12block-left which we'll learn about in the next movie.
01:15Then we have block-user template and block-user-1 template, both being able to
01:21affect the navigation block, since it comes from the user module.
01:25Now we want to affect all the blocks that come from the User module, so we won't
01:30use the one with the -1 in the file name, but instead just block-user.tpl.php.
01:38This block template will affect all the blocks in the user module.
01:43Let's go to our theme folder and let's copy the block.tpl.php file and paste it.
01:52We want to rename this file to block-user.tpl .php and open this file in our text editor.
02:02So since this block is just like all the other blocks, we could do a couple of
02:07things here that are different.
02:09One of the changes, I would like to make to all the user blocks is to change the
02:14heading tag used for the block title.
02:17For the user blocks, I just want to change the <h2> tag to an <h4> tag.
02:22Let's see that change now take place in our Drupal site.
02:25So I'm going to minimize my text editor, I'm going to go back to the Drupal
02:30theme administration screen, I'm going to click Refresh, so Drupal updates its
02:35information about our theme folder, recognizing the new block template.
02:39I'm going to go back to my Sunflowers screen and I'm going to click Refresh on this page.
02:45Now we can actually inspect with Firebug, the headings for the user blocks.
02:52Now we see that in the navigation block, an <h4> tag is used for the title.
02:57It's styled the same because our style.css file has multiple styles for
03:03different heading sizes.
03:05Let's scroll down to the bottom and look at the who's new and who's online headers.
03:10We now see that the who's new title is also an <h4> tag and we can assume that
03:15the who's online is also the same and it is.
03:19Notice the heading is a different size from the other blocks because we're only
03:23affecting the blocks that come out of the user module.
03:26By now there should be a pattern forming in your head about how Drupal looks
03:30for theme templates.
03:32When taking this info and applying it to your own work, remember, most
03:36third-party modules can be themed through these same template schemes.
Collapse this transcript
Creating a template to theme all blocks in a certain region (block-region.tpl.php)
00:00Drupal blocks in any theme region can receive their own template, which would be
00:04used over a standard block template.
00:08For example, the right sidebar blocks could have a different heading tag over
00:11any of the other blocks that appear in other regions.
00:14In this video, I will create a block template that will only affect the blocks
00:19that appear in a single region.
00:21In this case, we will be modifying blocks in the right sidebar.
00:25So to figure out what the naming convention will be for this special block
00:29template that affects only the right sidebar region, we'll turn on our
00:34Theme developer module.
00:35If you don't have this module enabled, be sure to turn it on inside your Drupal
00:40administration Modules page.
00:42Since I have my Theme developer module already enabled, I'm just going to turn
00:46it on by clicking Themer info.
00:49We see this dialog come up and now I'm going to click right on one of the blocks
00:54that appear in the right sidebar region.
00:56So now I'm going to look at the candidate template files listed in the Theme
01:00developer module window.
01:01We're going to look for the block template that is named after the region, in
01:07this case, region right.
01:10So we see that there is a template that it recommends called
01:13block-right.tpl.php.
01:18This is the file we're going to want to create from our standard block template.
01:22So let's go ahead and minimize our browser.
01:25And let's look at our theme folder, hanselandpetal, that's
01:27inside sites/all/themes.
01:28And we're going to copy the standard block template and paste this copy to
01:36rename this block-right.tpl.php.
01:43Now that we have our file, let's edit it in our text editor.
01:46So now let's scroll down and let's edit the heading tag used for the
01:51right sidebar blocks.
01:54Instead of an <h2> tag, I'm choosing to use an <h3> tag.
01:57I'm going to minimize Dreamweaver.
01:59I'm going to go back to Drupal and go into the Themes administration page and click Refresh.
02:06This refresh now updates the internal theme cache in Drupal and lets Drupal go
02:11through our theme folder to find a new template.
02:15Let's go back to the Sunflowers page and click Refresh.
02:20Now we didn't notice the difference, but if we actually inspect this tag,
02:25we can see we're now using an <h3> tag instead of the <h2> tag for all the other standard blocks.
02:32The reason why we didn't see the styles change is because the style sheet
02:36actually has styles declared for <h2> , <h3>, and <h4> tags, so all of
02:42those would have worked.
02:43If I look at this second block in the sidebar region, we can also confirm that
02:48this block, which comes from a totally different core module, has the same
02:53heading tag because it lies in the same region as the search block.
02:58All the blocks that we would then put inside the right sidebar are going to get
03:03this new <h3> tag for their title.
03:05Again, if CSS alone cannot accomplish your customization to a block or set of blocks,
03:11then creating these additional block templates makes sense.
Collapse this transcript
10. Other Templates
Exploring the comments template (comment.tpl.php)
00:00Drupal's origin is in social publishing.
00:03That's why there are many community related features built-in, like the
00:07ability to leave comments.
00:09Site visitors can leave comments on content you post in Drupal.
00:14In this video we will create a modified template to control the display of
00:18comments across our flower site.
00:20So I will actually need to create a few comments first before we can edit
00:25the template for them.
00:27So let me actually go down and click Add a new comment on one of the flower
00:31posts we have called Sunflower.
00:34So the subject line I am going to go say I like this flower, and for the Comment
00:41I am going to go say, Great site!
00:43I am going to go click Preview.
00:46That's what the comments are going to look like right now. That's good.
00:49And I am going to go click Save to actually save the comment to the node.
00:55As we see now, there is a new comment on this flower post.
00:57Now, I am going to create another comment right after that.
01:01And this one will be a little bit different.
01:02And it will say I like orange more than yellow.
01:08My flower is pretty.
01:12Your flower is just yellow.
01:15So of course we have to Preview. This is what it will look like now.
01:18We click Save on this comment, and now we have two comments that we can go and
01:23modify their template, and we will see a change when we refresh this page.
01:28So the first step in this workflow is to actually get the comment template out
01:32of the drupal-6 core folder.
01:35This is available in the modules comment folder, and the file
01:40is comment.tpl.php.
01:45So we are going to actually want to copy this file, minimize my Drupal folder.
01:50Let's go to our hanselandpetal theme in sites/all/themes and we are going to
01:54paste this comment template into our theme folder.
01:58Now let's edit this file, and of course like all the other templates, the first
02:02thing we do when we are modifying a template from core is we will remove the
02:07previous author's information. Click Save.
02:10And just like the previous templates we learned about, there are some variables
02:14available to this template.
02:15I am going to scroll down, and I actually want to make a small change to this template.
02:21I am going to go back to my Drupal site.
02:24I actually want to move where the Submitted by date is located.
02:28I would like this to be above the Subject line.
02:32So I am going to go back to my text editor, and I am actually going to look for
02:36the submitted code, and that's lines 38 to 40 in the standard comment template.
02:42I am going to go actually drag and move this code to be right before the heading
02:48tag, and the title variable.
02:49I am going to remove my extra white space and I am going to click Save.
02:53I am going to go now minimize Dreamweaver, and go back to my Themes
02:58Administration screen to refresh it, so Drupal can then pick up the changes
03:03in my theme folder.
03:04So now that Drupal should recognize I have a custom comment template, I am going
03:09to go back to my Sunflower page and click Refresh.
03:13It looks like Drupal did not pick up my changes, so let's actually go back to
03:17the Theme Administration page and we will go down, click Save configuration.
03:22And this happens sometimes when Drupal just doesn't update its theme cache properly.
03:27So by clicking Save configuration on our Theme Administration page we now
03:32guarantee that Drupal has gone through all the theme files and cataloged what's new.
03:36So let's go back to our sunflower page.
03:39Let's click Refresh and now we see that our submitted line actually appears
03:44before our subject line from our comments.
03:48Now, I actually want to show you one more thing, because comments,
03:52their templates are similar to node templates, in that a comment on a flower node
03:58type can have a different template from all the other node types.
04:02In fact, the naming convention is very similar to the node type template we
04:06learned about in one of the preview chapters.
04:09Let me go activate my Theme Developer module, so we can see what I am talking about.
04:14So I am going to enable the Theme Developer module, along with the Devel module,
04:20click Save configuration in my Module screen, and now that we know that the
04:24Theme Developer module is on, I am going to go back and refresh my sunflower's page,
04:28and enable the Themer info window.
04:31I am going to go click on one of the comments, and we are going to see that the
04:35candidate template files could be named either comment.tpl.php or
04:42comment-flower.tpl.php.
04:47So if we would have maybe left comments on a blog type, this template
04:51recommendation would be comment-blog.tpl.php.
04:57Since I only need one template for my comments across my entire site,
05:01I will leave this as is.
05:03If you are building a site where comments will not be allowed, then you do not
05:07need to include this template in your theme.
05:10But if you plan to release your theme to the public, then I highly suggest
05:14you consider providing this template as other sites may have comments enabled for their content.
Collapse this transcript
Exploring other core modules and their templates (other tpl.php files)
00:00The last few chapters have detailed the common templates used by all Drupal themes.
00:06Drupal core has even more templates available to you, so you can include them
00:09in your own themes.
00:11In this video I will show you where to reference this list of templates, so you
00:15can create even better Drupal themes.
00:18So the list of templates is available on www.drupal.org.
00:21So I am going to go to my tab for the core templates and suggestions page.
00:26This is a reference sheet that has all the Drupal templates available in Drupal core.
00:32There is even a cheat sheet PDF you can download and view on your machine.
00:37So scrolling down we can see that there is an alphabetical list of every module
00:42that comes with Drupal, and the associating templates available for you to
00:48reference, and even incorporate into your own themes.
00:52We see modules like the Aggregator module located in the Drupal modules/
00:57aggregator folder, have actually five templates you could use.
01:02We learned already about the Block template, we learned about the Comment
01:06template, and of course the Node template.
01:09You can see that there's quite a few templates here, and if you notice a
01:13pattern, they always end in .tpl.php.
01:18So any third party module you might be adding to your Drupal site, you will want
01:22to check inside the module folder to see if there's any template files that you
01:27can duplicate and incorporate into your own theme.
01:31And if we scroll down even a little further, we get to what are known as the
01:34template suggestions list.
01:36Now, we have already covered quite a few of these, like the multiple block
01:40templates, and the multiple node templates.
01:44All of these template suggestions are ones that everybody should follow, because
01:48they actually allow you to get to the area of Drupal you would like to customize
01:54and create your own markup for.
01:56Now, our completed theme for this course does not use all these templates,
02:01just the main basic ones that we covered in the last few chapters, but there's
02:05nothing stopping you from getting these templates and incorporating them into
02:10the theme that we have been building throughout this course.
Collapse this transcript
11. Troubleshooting and Finishing Up
Removing unnecessary modules
00:00Early in this title, I introduced some useful modules for Drupal Theme development.
00:06Now that we're done building the flower shop theme, I need to disable those
00:09development modules.
00:11This should happen before any performance tuning takes place.
00:14This video makes sure all my Drupal development modules are disabled properly,
00:19so our flower site can run without any development baggage.
00:23So since I'm starting from the Themes administration page, I need to actually
00:28load up the Modules administration page.
00:31I could do that quickly on the left side navigation by clicking Modules.
00:35Now I'm going to open this in a new tab and scrolling down to any of the modules
00:40listed under Development.
00:42So I've got a quite a few here.
00:44So I'm going to first disable the Theme developer module and the Drupal
00:48for Firebug module.
00:49These modules need to be disabled first, before we can disable any of the
00:54dependent modules that they require.
00:57So let's click Save Configuration and we're going to scroll back down again and
01:02now you should see that you can disable the Devel module and the Drupal for
01:06Firebug Preprocessor module.
01:08So let's go and click Save configuration.
01:12And now that all our Development modules are actually disabled, we can move
01:17on to publishing the site and turning on any performance settings that will be needed.
01:23All development modules that you build your site with should be disabled or
01:28uninstalled entirely before you publish a site live.
01:31They're not needed to run the site and actually can hurt the performance of the site.
01:36So again, now that our development modules are disabled, we can move on to
01:40tuning the site for peak performance.
Collapse this transcript
Optimizing site performance
00:00Drupal has some good performance features out of the box.
00:04A great feature of Drupal is the ability to compress CSS files used across the site
00:08into single style sheets, resulting in faster page loads.
00:12In this video, I will enable CSS compression and show how that affects our site.
00:18So before I turn on the Performance Settings, I want to on a show you what
00:21Drupal is actually outputting right now, before compression is turned on.
00:26So if I View Source on my Sunflowers page, we see that there are actually quite
00:31a few module style sheets as they come from the modules folder, and we have a
00:36couple style sheets ourselves for our theme.
00:40Now, what I want to do is turn on compression for CSS and what we'll see is all
00:45the module style sheets will compress themselves into one style sheet.
00:49Well, our theme will also be changed into a single compressed style sheet, making
00:55it a little bit smaller and pages load faster.
00:59And will see our style sheet for our theme will also be compressed, resulting
01:03in little bit more faster page loads than what we get out of the box without compression on.
01:09So I'm going to close the source file.
01:11Now I'm going to go back to my Drupal administration screen.
01:15Starting from the Administer screen, I'm going to scroll down and click on Performance.
01:20Now, we're not going to review any of the caching stuff up on top.
01:24I want to go down to the Bandwidth optimization section.
01:27I want to turn on the Optimize CSS files option and we can even turn on the
01:33Optimize JavaScript files option as well because we have a few JavaScript files
01:38that we include in our theme and we can get those compressed as well.
01:41Now that I have these two options enabled, I'm going to click
01:44Save configuration.
01:45If we go back to our Sunflower page and click Refresh and now if we view the
01:51source of this page, we see that the style sheets have been dramatically
01:55compressed down to one long special style sheet that Drupal has created for us.
02:02We also see the same has happened to the JavaScript files that are provided in our theme.
02:08Simple performance options, like enabling CSS and JS compression, can do wonders
02:13in speed for small and large sites.
Collapse this transcript
Streamlining site files for launch
00:00Not every file needs to be uploaded with Drupal for deployment.
00:05In this video, I'll show you what files can be either deleted or ignored during
00:10Drupal's deployment.
00:11So I am going to minimize my web browser, because we are going to only be
00:14dealing with the Drupal files in this video.
00:16All the folders we see here in Drupal have to be uploaded along with every
00:21PHP file we see listed.
00:24There are also just a couple extra files that need to go up as well.
00:29robots.txt and .htaccess, which is actually normally a hidden file on
00:36most operating systems.
00:38So if you do not see a .htaccess file on your machine, maybe your FTP program
00:44can see it and if not, you need to install some sort of utility that will let
00:49you actually see that file so you can upload it properly.
00:53All the other text files that I'm now highlighting do not need to be uploaded
00:58and can actually be ignored when deploying Drupal.
01:02Do not delete any core modules or any core themes.
01:06By removing these unnecessary text files, we reduce the footprint of Drupal just
01:10a little bit, and actually eliminate any surface risk of being spotted by
01:15malicious people who are trying to hunt down Drupal sites to try to exploit a
01:20bug that maybe some have.
01:22Only upload what is needed, always.
Collapse this transcript
Troubleshooting when a white screen appears instead of Drupal
00:01While using Drupal, you may run into a blank white screen.
00:04This can happen during installation or after enabling a new module.
00:08In this video, I want to take a look at that issue that happens most often
00:12on Mac OS X when using MAMP with Drupal, which is why we are looking at a Mac screen here.
00:18So by default, MAMP actually uses only a few megabytes of memory allocated to PHP.
00:25This can cause problems for Drupal as the minimum requirements for Drupal are
00:28usually higher than what MAMP ships with by default.
00:33If you are using MAMP PRO instead of the regular MAMP, you can check out
00:37this blog post that covers how to do what we're do in this video but from MAMP PRO instead.
00:43Since I am using just basic MAMP, I've already set up the database and I am
00:48going to start the installation process for Drupal now.
00:51I've not made any changes to MAMP yet, as we are going to see what happens
00:55during the installation with the default settings in MAMP, and then we'll go and
00:59fix the MAMP settings to get past the white screen.
01:03So I've already entered my information here for my local MAMP Drupal site.
01:07I am going to click Save and continue and we see that Drupal is starting
01:13the installation, we are going to fill out the required info and click Save and continue.
01:22And now we ended up with a blank white screen instead of the blue Drupal
01:26confirmation page that we expected to see.
01:30This is a problem built into MAMP and actually might happen on your own web
01:33server if PHP does not have enough memory to run Drupal.
01:38So to fix this, I actually need to go into my MAMP folder and tweak the php.ini file.
01:44So I am going to go into Applications, MAMP, and inside the conf folder,
01:51I'll visit the php5 and edit the php.ini file.
01:57I am going to use TextEdit and what we need to find here is the PHP max memory setting.
02:04So I am going to scroll down and you can actually do a find on the page for the
02:09setting memory_limit and we see here that 8 MB is the default value.
02:17I am going to bump this up to 128 since this is my local machine and I plan to
02:21do some development.
02:22We are going to File > Save and then we will quit our text editor, go back to
02:28MAMP, and we need to restart the MAMP Servers, so we do that by clicking Stop
02:33Servers and then Start Servers once MAMP is ready for us to do so.
02:38Now that we've turned back on the MAMP servers, we can minimize MAMP, go back
02:43to our Drupal installation, click Refresh, and Drupal now can complete its installation.
02:52MAMP and MAMP PRO, both seem to have this issue, but not the Acquia Drupal Mac
02:57Installer we used throughout this course.
03:00I'm not saying one is better than the other.
03:02Just the default settings for MAMP are not optimal for Drupal, so a small
03:06tweak was necessary.
03:08Knowing Drupal's minimum requirements is important when installing it anywhere, even locally.
Collapse this transcript
Touring Drupal community groups
00:01Since I've been involved with the Drupal community, the number one question I have
00:05has been, where do I go for help?
00:08Drupal has many areas that you can actually reach out to the Drupal community
00:12and ask for help directly.
00:15The best place is the Groups website, which is available at groups.drupal.org,
00:21because this is a whole site dedicated to geographical and online groups that
00:28basically huddle around certain topics.
00:31The key group in here for theme development is actually a group called Theme development.
00:37These groups are free to join, and are very informative.
00:41If you have a general question to the community and think one of these groups
00:44can help you, then I definitely recommend you joining the free website and
00:49joining the groups that make sense for you.
00:51Let me show you the group that I manage, which is the Los Angeles Drupal user group.
00:57You can actually join a regional group near your area and there's groups
01:01all over the world.
01:03Join your local group, join an online group, like the Theme development group,
01:08and start joining the Drupal conversation.
01:10Keeping connected to the community is one of the key strategies for Drupal,
01:15because that's been one of its largest strengths.
01:18So join one of these standard channels and keep up with the community.
Collapse this transcript
Conclusion
Goodbye
00:01Thank you for joining me for Drupal: Creating and Editing Custom Themes.
00:05I hope your Drupal theme comes out great, and maybe I'll get to see it online in the future.
Collapse this transcript


Suggested courses to watch next:

Dreamweaver with PHP and MySQL (4h 55m)
David Gassner


PHP with MySQL Essential Training (11h 3m)
Kevin Skoglund

Web Site Strategy and Planning (1h 37m)
Jen Kramer


Are you sure you want to delete this bookmark?

cancel

Bookmark this Tutorial

Name

Description

{0} characters left

Tags

Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading
cancel

bookmark this course

{0} characters left Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading

Error:

go to playlists »

Create new playlist

name:
description:
save cancel

You must be a lynda.com member to watch this video.

Every course in the lynda.com library contains free videos that let you assess the quality of our tutorials before you subscribe—just click on the blue links to watch them. Become a member to access all 98,466 instructional videos.

start free trial learn more

If you are already an active lynda.com member, please log in to access the lynda.com library.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Access to lynda.com videos

Your organization has a limited access membership to the lynda.com library that allows access to only a specific, limited selection of courses.

You don't have access to this video.

You're logged in as an account administrator, but your membership is not active.

Contact a Training Solutions Advisor at 1 (888) 335-9632.

How to access this video.

If this course is one of your five classes, then your class currently isn't in session.

If you want to watch this video and it is not part of your class, upgrade your membership for unlimited access to the full library of 1,893 courses anytime, anywhere.

learn more upgrade

You can always watch the free content included in every course.

Questions? Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com.

You don't have access to this video.

You're logged in as an account administrator, but your membership is no longer active. You can still access reports and account information.

To reactivate your account, contact a Training Solutions Advisor at 1 1 (888) 335-9632.

Need help accessing this video?

You can't access this video from your master administrator account.

Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com for help accessing this video.


site feedback

Thanks for signing up.

We’ll send you a confirmation email shortly.


By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked