ich versuche mich an der Entwicklung eines Addons und nutze dafür das Beispiel-Addon ADRESSEN (http://www.redaxo.org/de/download/addon ... &cat_id=-1).
Als Test-Objekt habe ich mich an einem Veranstaltungskalender versucht.
Bislang klappt alles super, allerdings komme ich bei einer Sache nicht weiter:
Vergangene Termine sollen automatisch gelöscht werden, bzw. den Status 'offline' bekommen.
Das Script (pages/events.inc.php) sieht folgendermaßen aus:
Code: Alles auswählen
<?php
$id = rex_request('id', 'int');
// Eintragsliste
if ($func == '') {
$list = new rex_list('SELECT id, start_date, start_time, event_name,event_desc,event_location, status FROM '.$REX['TABLE_PREFIX'].'900_events', 200);
$imgHeader = '<a href="'. $list->getUrl(array('func' => 'add')) .'"><img src="media/metainfo_plus.gif" alt="add" title="add" /></a>';
// Sortierbare Spaltenkoepfe
$list->setColumnSortable('start_date');
$list->setColumnSortable('event_name');
$list->addColumn(
$imgHeader,
'<img src="media/metainfo.gif" alt="field" title="field" />',
0,
array(
'<th class="rex-icon">###VALUE###</th>',
'<td class="rex-icon">###VALUE###</td>'
)
);
$list->setColumnParams (
$imgHeader,
array('func' => 'edit', 'id' => '###id###')
);
// Beschriftungen für Spaltenköpfe
$list->setColumnLabel('start_date', 'Startdatum');
$list->setColumnLabel('start_time', 'Uhrzeit');
$list->setColumnLabel('event_name', 'Name');
$list->setColumnLabel('event_pic', 'Bild');
$list->setColumnLabel('event_desc', 'Beschreibung');
$list->setColumnLabel('event_location', 'Location');
$list->setColumnLabel('status', 'On/Offline');
$list->setColumnLayout (
'id',
array(
'<th class="rex-icon">###VALUE###</th>',
'<td class="rex-icon">###VALUE###</td>'
)
);
$list->setColumnParams('name', array('func' => 'edit', 'id' => '###id###'));
$list->show();
}
// Formular
elseif ($func == 'edit' || $func == 'add') {
$form = new rex_form($REX['TABLE_PREFIX'].'900_events',"Events","id=".$id,"post",false);
// Formularfelder anlegen
$field = &$form->addTextField('start_date');
$field->setAttribute('class','date-pick');
$field->setAttribute('id','start-date');
$field->setLabel("Startdatum");
$field = &$form->addTextField('start_time');
$field->setLabel("Uhrzeit");
$field->setAttribute('size','5');
$field = &$form->addTextField('end_date');
$field->setAttribute('class','date-pick');
$field->setAttribute('id','end-date');
$field->setLabel("Enddatum");
$field = &$form->addTextField('event_name');
$field->setLabel("Name der Veranstaltung");
$field = &$form->addMediaField('event_pic');
$field->setLabel("Grafik/Bild zur Veranstaltung");
$field = &$form->addTextAreaField('event_desc');
$field->setLabel("Beschreibung");
$field = &$form->addSelectField('status');
$field->setLabel("Status");
$select = &$field->getSelect();
$select->setSize(1);
$select->addOption('Online',1);
$select->addOption('Offline',0);
$select->setAttribute('style','width: 100px');
// Standardwert: 1
if ($field->getValue()== "") {
$field->setValue(1);
}
// Selectfeld für Veranstaltungsorte
// Werte werden aus der Locations-Tabelle geholt
$field = &$form->addSelectField('event_location');
$field->setLabel("Location");
$select =& $field->getSelect();
$select->setSize(1);
$query = 'SELECT name as label, id FROM '.$REX['TABLE_PREFIX'].'900_locations';
$select->addSqlOptions($query);
if($func == 'edit') {
$form->addParam('id', $id);
}
$form->show();
}
?>
Ich hoffe ihr könnt mir helfen.
Viele Grüße