Drupal 7 Theming – How To Do Html5-thinkpad s230u

In this blog post well be discussing about how to do HTML5 in Drupal 7. Apart from HTML5, we will also cover how to remove some of the generated markup that Drupal provides by default, and how to override default system CSS. Well also look at a few tips on how to get some quick-win page speed boosts. Before we probe in deeper, its good to mention that this post is not a comprehensive tutorial on building a Drupal 7 theme. For the sake of briefness, we wont be able to cover the HTML5 Tools module, which helps to add features like new HTML5 form elements to Drupal. Rather than that, we will focus on reducing the superfluous XHTML that Drupal still unconsciously wants to include, as an inheritance from its earlier stages. Structure At the time you first install Drupal, you will be able to see a top-level directory named themes. It is only apparent that youll be thinking that this is where you should store your own theme related files. However, in this case, this is wrong. Actually, the directory you want to play in is sites. This is all about you and your particular site, and within this is another themes directory that will be housing your themes. It is important to note that Drupal can handle multiple domains via a single codebase, and thus, the sites directory instead of site, but we would not be discussing about it in detail, as it is beyond the scope of this article. To know more on this topic, then theres a Multisite Drupal group that is dedicated to the topic. As a first step, the initial thing to do is to create a *.info file with the name of your theme. Since our site is Valuebound.com, and our theme is aptly named Valuebound, our info file is valuebound.info. the following are the contents (; comments out a line): ; BASIC SETTINGS name = Valuebound core = 7.x ; FEATURES (intentionally blank) features[] = ; REGIONS regions[front_journal] = front_journal regions[content] = content regions[sidebar_first] = sidebar_first regions[sidebar_second] = sidebar_second regions[search] = search ; CSS stylesheets[all][] = assets/css/override/kill/ctools.css stylesheets[all][] = assets/css/override/kill/field.css stylesheets[all][] = assets/css/override/kill/node.css stylesheets[all][] = assets/css/override/kill/system.messages.css stylesheets[all][] = assets/css/override/kill/system.menus.css stylesheets[all][] = assets/css/override/kill/user.css stylesheets[all][] = assets/css/override/kill/views.css stylesheets[all][] = assets/css/reset.css stylesheets[all][] = assets/css/override/keep/system.base.css stylesheets[all][] = assets/css/override/keep/system.theme.css stylesheets[all][] = assets/css/override/keep/search.css stylesheets[all][] = assets/css/960_12_col.css stylesheets[all][] = assets/css/text.css stylesheets[all][] = assets/css/formalize.css stylesheets[all][] = assets/css/site.css ; JAVASCRIPT scripts[] = assets/js/master.min.js Aggregation If you are familiar with the Drupal themes, then youd observe that the preceding code is pretty straightforward stuff, there nothing that is too extra-ordinary. Another thing, that you might have noticed is the override directory. Within it are two other directories, kill and keep. We also learned a clever way to get rid of system CSS files that we dont want. If you name one of your own CSS files the same as one of the defaults, Drupal will include yours rather than providing its own. Thus, everything in the kill directory is just an empty file, whereas everything in the keep directory is a CSS file thats been only slightly or not modified from its original defaults. So, its natural if you are wondering Why bother to have a keep directory at all, if Im reusing the very same code as the default files it contains? Heres where it starts to get interesting. When you go to the Performance admin page, and turn on aggregation and compression of CSS files, Drupal will gather up all its default system stylesheets into a single file, and all your stylesheets into another. It may sound silly. But with our keep directory, we force those default stylesheets along with our theme stylesheets, to be aggregated and compressed into one file. Template.php Section One of our old practice from the early CMS days, which we havent given up is using Textpattern. This is because for theming purposes we like to know what section of the site we are on. Basically, that just means that were curious what foobar is equal to, in the following scenarios: .example.com/foobar .example.com/foobar?page=1 .example../foobar/node/search%20term Thus, at the beginning of our template.php file, we have a simple function that runs through and gets us the first path fragment in the URL, it does a simple switch/case, and returns a string that be.es the ID. After HTML5 /* Code here. */ /* Code here. */ Template.php Minification Although this doesnt actually apply to HTML5 directly, we decided that while we were mucking about in the template.php file, we might as well add some HTML minification. Essentially, the following code just strips out unnecessary whitespace and line breaks, saving a bit of file size wherever possible. If a page contains a or tag, it is left alone, as to not affect code blocks or text typed in a form. // Minify HTML output. function valuebound_process_html(&$vars) { $before = array( "/>\s\s+/", "/\s\s+\t+"> page.tpl.php By: Jennifer Maria – In todays time, when everyone is exploiting the web, you cannot afford to ignore the Internet. If you want to be in the race, you must harness the power of the web. And … By: Neal David – For many people who are conscious about staying healthy and fit various fitness devices hold a lot of appeal. Managing your fitness regime be.es very easy when you have … By: Aaron – Some honest to goodness organizations offer you a guarantee period of the services they have offered. They have confidence in the nature of the work they convey. You can c … By: Neal David – The literal meaning of the word "mobile" is to a certain extent lost due to the wired chargers which kind of limits the freedom of consumers to use their mobile handsets i … By: smartweb – Homeowners Association(HOA) is an American corporation established by the real estate world for the purpose of marketing, managing, selling and buying ofproperties. By: Neal David – Note 5 screen protector from MXx has gained a lot of popularity, but, before you decide to buy one for yourself, why not examine its features closely? Yes, this screen pro … By: Neal David – Smart phones are very essential part of our lives. It is not just a phone but a gadget with multiple utilities and to get the best of all worlds we love to spend as much a … By: jaspreet sason – Software is very user-friendly. Software is not only used in .puters. These are used in so many devices such as in washing machine, robots, microwaves, satellites, mobil … By: Neal David – Many enthusiast travelers and other mobile hand set users (almost the entire population, obviously) would have faced a situation sometime in their lives when they are out … By: Neal David – It is often claimed by experienced users that any metric which cannot be quantified cannot be tracked and monitored. This is one of the most relevant problems in fitness s … 相关的主题文章: