Drupal 7 fields: Unterschied zwischen den Versionen
Erscheinungsbild
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 36: | Zeile 36: | ||
endforeach; | endforeach; | ||
?> | ?> | ||
==Datums Feld anpassen und berechnen== | |||
<?php | |||
$days = format_date(strtotime($content['field_erledigt_bis']['#items'][0]['value']), 'custom', 'd.m.y'); | |||
$date = strtotime(date("Y-m-d", strtotime($days)) . " +0 day"); | |||
$dt = new DateTime("@$date"); // convert UNIX timestamp to PHP DateTime | |||
echo $dt->format('d.m.Y'); // output = 2012-08-15 00:00:00 | |||
?> | |||
==Field in Block anzeigen== | ==Field in Block anzeigen== | ||
Version vom 26. März 2013, 17:00 Uhr
Fields für node.tpl.php
http://api.drupal.org/api/drupal/modules!field!theme!field.tpl.php/7
- Content
<?php
hide($content['title']);
hide($content);
?>
- Caption
<?php print render($content['field_news_caption1']); ?>
- Field
<?php print render($content['field_address1']); ?>
- Title
<?php print render($content['title']); ?>
- Body
<?php print render($content['body']); ?>
- Images im Node anzeigen
<?php
$my_image = array(
'style_name' => 'thumbnail', //the image style created
'path' => $node->field_flyin_portrait['und'][0]['uri'],
);
print theme('image_style', $my_image); ?>
Fields Templete field--field_bilder.tpl.php
Datei erstelln, wie das Field heisst. zB. field--field_fieldname.tpl.php das Beispliel ist für deine Bildergalerie gedacht.
<?php
foreach ($items as $delta => $item) :
print render($item);
endforeach;
?>
Datums Feld anpassen und berechnen
<?php
$days = format_date(strtotime($content['field_erledigt_bis']['#items'][0]['value']), 'custom', 'd.m.y');
$date = strtotime(date("Y-m-d", strtotime($days)) . " +0 day");
$dt = new DateTime("@$date"); // convert UNIX timestamp to PHP DateTime
echo $dt->format('d.m.Y'); // output = 2012-08-15 00:00:00
?>
Field in Block anzeigen
- beim Nodetype eine fild erstellen
- Field Type = Bild
- Bild Stiel anpassen
- eine View erstellen welche als Block dargestellt wird.
- format = Felder
- unter Kontextfilter
- Vorgabewert bereitstellen
- Typ = Beitrags-ID Aus der URL
- "Skip default argument for view URL" Hacken Setzen
Speichern und Fertig :D