Hi guys,
i am trying to complete this task (adding a field to a module) for days now but cant find any solution.
I created a module that works and shows results on my website.
My task is to add a field you can enter keywords -> press search button and get all the results listed.
The module creates a block that shows my results at the moment.
Here is what i have right now:
/**
* Hilfe zum Modul
* @param section - wo auf der Seite wird die Hilfe angezeigt
* @return - der Hilfetext des Moduls
*/
function artikelsuche_help($section='') {
$output = '';
switch ($section) {
case "admin/help#artikelsuche":
$output = '<p>'. t("Artikelsuche nach SKU oder Artikelname"). '</p>';
break;
}
return $output;
} // function artikelsuche_help
/* Mögliche Zugriffsrechte für dieses Modul */
function artikelsuche_perm() {
return array('access artikelsuche content', 'administer artikelsuche');
} // function artikelsuche_perm
/*
* Funktion des Blocks
* $op == list -> Name des Blocks in der Block-Übersicht
* $op == view -> Inhalt des Blocks der auf Seite dargestellt wird
*/
function artikelsuche_block($op='list', $delta=0) {
// listing of blocks, such as on the admin/block page
if ($op == "list") {
$block[0]["info"] = t("artikelsuche");
return $block;
}
else if ($op == 'view') {
// Block Inhalt
// Contentvariable die den Blockinhalt zurückgibt
$block_content = '';
//AB HIER BEGINNT DER EIGENTLICHE INHALT
//THIS QUERY SHOULD HAVE THE VARIABLE FROM THE SEARCH FIELD IN IT
$query = "SELECT nid, title FROM {node} WHERE (type = 'content_random_products' OR type = 'content_random_stock' OR type = 'product') AND status = 1";
// Links erstellen
$queryResult = db_query($query);
while ($links = db_fetch_object($queryResult)) {
$block_content .= l($links->title, 'node/'.$links->nid) . '<br />';
}
// Wenn keine Ergebnisse gefunden wurden
if ($block_content == '') {
return;
}
// Block erzeugen
$block['subject'] = 'Artikelsuche';
$block['content'] = $block_content;
return $block;
}
}
Sorry for any mistakes, english is not my native language
Thanks in advance!
David
EDIT:
This is basically what i try to achieve:
https://www.drupal.org/node/57349
my version:
function quickmail_perm(){
return array ('can send quickmail');
}
function
quickmail_block($op = "list", $delta = 0) {
if ($op == 'list') {
$block[0]['info'] = t('Quickmail Block');
return $block;
}
elseif ($op == 'view') {
$block['subject'] = 'Quickmail';
$block['content'] = quickmail_form();
return $block;
}
}
function
quickmail_form($edit = null) {
$form['details']['firma'] = array(
'#type' => 'textfield',
'#title' => t('Firma'),
'#default_value' => $edit['firma'],
'#size' => 15,
'#maxlength' => 128,
'#description' => null,
'#attributes' => null,
'#required' => true,
);
$form['details']['telefon'] = array(
'#type' => 'textfield',
'#title' => t('Telefon Nr.'),
'#default_value' => $edit['telefon'],
'#size' => 15,
'#maxlength' => 128,
'#description' => t('Geben Sie hier die Telefon Nr. ein unter der Sie unseren Rückruf erwarten.'),
'#attributes' => null,
'#required' => true,
);
return drupal_get_form('quickmail_form', $form);
}
But this just loads a few seconds and leaves my page white.
Removing the $block['content'] = quickmail_form(); line changes it so that i see my page again but without the needed fields of course.
Comments
bump
Does nobody know a solution or is anything wrong with the question?
I am new to this forum.
Thanks in advace,
David