programatically create CCK forms in Drupal 6

19.11.2008 von Lukas Fischer | 0 Kommentare

This is the solution:

<?php
$new_blognode = new stdClass();
$new_blognode->type = 'blog';
module_load_include('inc', 'node', 'node.pages');
$output .= drupal_get_form('blog_node_form', $new_blognode);
?>

Mehr

Drupal praktisch 2 - E-Mail Validierung

21.08.2008 von Lukas Fischer | 0 Kommentare

Kürzlich hatte ich das Problem, eine E-Mail Adresse von einem Drupal Formular zu validieren. Dieser Codeschnipsel löst die Aufgabe sehr einfach und ist zudem flexibel erweiterbar. Falls der Regex nicht genügt, findet man auf
http://www.txt2re.com weitere Rexex Regeln.

function FROM_validate($form_id, $form_values) {
  if (!preg_match('([\\w-]+(?:\\.[\\w-]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})', $form_values['EMAILFIELD'])) {
    form_set_error('', t('Bitte korrekte E-Mail Adresse angeben.'));
  }
}
Mehr

Drupal praktisch 1 - Table Themer

20.08.2008 von Lukas Fischer | 0 Kommentare

Ein typische Anwendung in CMS Administrationen ist das tabellarische Auflisten von Einträge. Das händische programmieren von Tabellen nimmt einem Drupal elegant ab.

// $nodes ist ein Node-Array
foreach ($nodes as $node) {
    	$rows[] = array(''.$node->title.'',
    			'Edit');
}
$header = array('Titel', 'Option');
$output .= theme_table($header, $rows);
Mehr

Inhalt abgleichen


2003-2008 | netnode IT services GmbH