Improve your Drupal theme markup with body classes

Since Drupal 6, a lot of the detailed markup as found in the excellent Zen theme framework has made its way into the default Drupal markup. More details about this feature can be found here https://drupal.org/node/163723

To use this feature for your theme just insert the variable

 
$body_classes 

into your tpl files body opening tag

 
 

like this

 

The result will be something like this

 

How to create and use a Drupal template (tpl) file

Template files are used to overwrite the core Drupal output (or the output of a module that overwrites the core Drupal output).

This can be for example useful if the layout of a particular content type, page, block or view can’t be easily fixed by a stylesheet. With a tpl file you can completely overwrite all output by using HTML/ CSS/ PHP/ Javascript/ …

This can be done by placing tpl.php files inside the theme folder. The naming of the files needs to follow a hierarchy in order for Drupal to pick up exactly which file you’d like to overwrite.

The hierarchy structure is as follows (top overwrites bottom):

For pages:
page-node-edit.tpl.php
page-node-1.tpl.php
page-node.tpl.php
page.tpl.php

For nodes:
node-type.tpl.php
node.tpl.php

For comments:
comment.tpl.php

For blocks:
block-module-delta.tpl.php
block-module.tpl.php
block-region.tpl.php
block.tpl.php

For boxes:
box.tpl.php

Taxonomy:
page-vocabularyname-termname1-termname2.tpl.php
page-vocabularyname-termname1.tpl.php
page-vocabularyname.tpl.php

Some popular examples:
page-front.tpl.php (home page)
page-admin.tpl.php
page-login.tpl.php
search-theme-form.tpl.php (search form)
search-result.tpl.php (search result)

Often a good start after you have created the new file is to copy and paste the content of the template you want to overwrite into your new template. Template files can be found in the following locations:

Drupal core themes: themes
Drupal core modules: modules
Modules: sites/all/modules
Themes: sites/all/themes

For more information see the Drupal.org website: https://drupal.org/theme-guide/6-7

How to add a new widget area to your WordPress theme

Most WordPress Themes come by default with some pre-defined areas where you can drop your widgets in. But often this is not enough and you need to add additional areas, for example for advertising space or other features.

This is how to do it:

First Step: Add widget Area to Theme
In the index.php file in your theme directory (/wp-content/themes/mytheme), add the following code in the area where you would like a new widget to appear. Note we have had to wrap this line of code so it displays. Careful of too many spaces.


Second Step: Function.php

Put this line at the end of the function.php file:

register_sidebar(array('name'=>'Post Widget',));

Third Step: Style

Now you can style the new widget area via stylesheet, example:

.widget_post {
	background: #FFFFFF;
	margin: 0px;
	padding: 10px;
	width: 600px;
	}

And then go to the WordPress backend and look in the widget section for the newly created area and drop in your desired widget. That’s it 🙂

W3C Validation

kleinermann web design validates all it’s clients’ websites with the W3C Validator to make sure the websites run well on different browser types.

Please check your website here: https://validator.w3.org/

Errors
The most common error declared by the W3C Validator is know as a “Syntax Error”. HTML and XHTML are languages used within the coding of the website and W3C produce an approved list of commands (words that are used in the language). If a website developer has used a non-approved command (word) then a Syntax Error is produced. The website may still appear to work and display properly but it does not achieve the levels of accessibility required by the W3C.

Warnings
Unlike errors, warnings are produced when the W3C validator is unable to make sense of the coding the developer has used in the website. It is sometimes the case that the commands used are so different from the list of approved HTML and XHTML commands that the W3C are unable to give the developer advice on how to correct the problem. Even more seriously, this could mean that the website has the potential to crash or not function properly.

Contact us if you have any questions regarding the results. We would love to give you some free advise.

x


Angebot anfordern

Ich melde mich innerhalb von 24 Stunden zurück.