Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
As we continue the process of migrating from Drupal 6 to Drupal 7, we're beginning to take a look at block templates. However, for this particular design, the only thing that's really changing is the heading on the blocks from h2 to h3 to h4. So we'll go ahead and take a look at exactly what we need to do, what the process of migration for this particular section is very simple. If we take a look at the Hansel & Petal Drupal 6 version and then open up Firebug and take a look at the left- hand side blocks, we can see that for this particular block for admin, it hasn't heading of h4.
If I introspect the recent blocks post, I see a heading of h2. And then if I take a look finally at the blocks on the right-hand side, I see that they have a heading of h3, and this is all based off of how the block templates are working. So let's actually browse over to our editor and take a look. The first thing I am actually going to do is grab a hold of the modules>block>block.tpl. I am going to copy it and I am going to paste it into our sites>all>themes> hanselandpetal>templates folder.
Right-click, paste and then go ahead and open it. If I scroll down and take a look, we see that currently, the default is an h2 heading for any of the titles. So as far as actually doing a migration of this point, we are perfect for what we actually have and there is no real change that needs to take place. But for the right-hand sidebar, if I want to make sure that all the blocks that are part of that region have a different heading, I can simply make a copy of this block and rename it based off the template suggestions to block--sidebar_second.tpl. php. Let's do that now.
I am going to copy and paste the same template back in and then give it the new name based off that template suggestion. So block--sidebar_second.tpl.php. I am going to go ahead and click OK and then open up that block, scroll down, and change the h2 to be an h4.
Go ahead and save that template, browse back over to our Drupal 7 instance, close Firebug for a second and then click on the Performance tab and clear all the cache. Close the performance interface and we're not going to see any real change unless we actually take a look at it through Firebug. So let's open up Firebug and inspect the Search element. We can see that the title on here is a title of h4 and if we scroll down and take a look at the syndicate block, we should also see an h4 and we do.
Go ahead and close Firebug, scroll back up to the top and now if we start to do a comparison once again between our Hansel & Petal 7 site and our Hansel & Petal 6 site, we should start to see similarities between these. The only thing that we really have left is to clean up some of the CSS to make sure that these themes completely match 100%. So while the only thing that we currently change was headings for the title, the process of converting block templates is not very complicated. Let's move on to tackling the remaining miscellaneous template conversions and CSS cleanup in Drupal 7.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.