Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:

Archived entries for theming

Theming Custom Entities in Drupal 7

Scott Lewis erklärt wie man eigene Entities in Drupal 7 themen kann.

I expected to be able to simply create a template file named {entity_type}.tpl.php following the same format as node.tpl.php or page.tpl.php but that did not work. I was able to create an alternate page template specific to my entity type in the format page–{entity_type).tpl.php. The problem with this approach, however, is that it requires reconstructing the entire page just to theme the entity output. This isn’t exactly what I wanted. What I want to do is create a custom theme for the entity output only.

Drupal 7: Theming Changes

Jack Haas beschreibt einige Änderungen im Theming von Drupal 7 Seiten.

hide() und render() sind extrem praktisch. Das hook_form_alter() auch auf der Theme Ebene über yourtheme_form_alter ansprechbar ist hatte ich schon gelesen, aber anscheinend gilt das für alle _alter() Funktionen:

Aaron Winborn discovered today that ALL _alter functions are now available to the theme layer in D7 (currently happening in the middle of drupal_alter() if you’re curious). This allows for things like hook_js_alter() or hook_css_alter() in themes, which some of you may find useful.

Drupal: JavaScript Theme Functions

Engineered Web erklärt Drupal JavaScript Theme Funktionen und wie man sie überschreiben kann.

Eine eigene Theme Funktion wird so definiert:

Dupal.theme.prototype.displayName = function(name, url) {
 return '<a href="' + url + '">' + name + '</a>';
}
// usage
var name = "John Doe";
var url = "http://example.com";
var display = Drupal.theme('displayName', name, url);

Ein Themer kann diese Funktion mit einem leicht anderen Funktionsaufruf überschreiben:

Dupal.theme.displayName = function(name, url) {
 return '<a href="' + url + '"><em>' + name + '</em></a>';
}

Theming Node Forms

Ich habe zwar (leider) noch immer keine Seite mit Drupal 7 realisiert, aber egal. Die Themingmöglichkeiten in Drupal 7 sind trotzdem immer spannend:. Hier Theming Node Forms in Drupal 7.

Here is an example of how to theme the layout of node form using the theme engine in Drupal 7. We will theme the article content type, provided by default with Drupal 7.
Suppose that the article content type, has a taxonomy field field_tags. I want to put the taxonomy field in a seperated region called sidebar.
Also the form buttons, will be extracted and printed as $buttons variable, in seperated region.
Please note that Node form columns module can be alternative for this example.
First of all, let’s implement hook_theme(). You can implement it in your theme’s template.php or your custom theme. In our case we will do it in a custom module. Let’s call it MYMODULE.
Our theme output, will be through the template file article-node-form.tpl.php.

Theming CCK fields

Netter Screencast auf Friendly Drupal über CCK Fields Theming.

Using CCK field templates
CCK comes with a default field template, called content-field.tpl.php. Copy it from the module directory (cck/theme) to your theme.
In addition to the default template, you also have several template suggestions based on it.
As typical with Drupal, the more specific options (e.g. the last one in the list) would have a precedence over the more generic one.
When you open content-field.tpl.php, you’ll see available variables such as $field_name or even the $node object. (…)
Using Drupal preprocess functions.
In what situation preprocess functions are preferable to working directly with the templates? Well, for one thing, you’re likely to end up with a ton of different templates with a serious downside in terms of maintenance. Or, just like in our example, you might need to use some piece of code that is shared across several fields but has to display different contents depending on the field or other context.
Let’s begin by opening template.php file for your theme (create it if there isn’t one yet). Then you can add preprocess function for the field template:
function your_theme_preprocess_content_field(&$vars) { // code here }



Copyright © 2004–2009. All rights reserved. – Impressum

RSS Feed. This blog is proudly powered by Wordpress and uses Modern Clix, a theme by Rodrigo Galindez.