-
Modul erstellen
Ich möchte gerne ein kleines Modul schreiben mmit dem ich GPX Files Verwalten kann
Ich möchte einen Titel, eine Beschreibung und ein Bild anlegen. Und das File auswählen.
Aus irgend einem Grund werden die Daten nicht gespeichert und in der Übersicht angezeigt.
Das Modul wird im BA angezeigt und auch zwei Datensätze.
Es stehen aber bei der übersicht wo man einen Datensatz auswählt und in den Feldern keine Daten drinnen.
Die DB lautet 'tl_gpx_tracks'.
Code:
CREATE TABLE `tl_gpx_tracks` (
`id` int(10) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`sorting` int(10) unsigned NOT NULL default '0',
`title` varchar(64) NOT NULL default '',
`beschreibung` text NULL,
`gpxfile` varchar(64) NOT NULL default '',
`image` varchar(256) NOT NULL default '',
`tstamp` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Code:
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
/**
* Contao Open Source CMS
* Copyright (C) 2005-2011 Leo Feyer
*
* Formerly known as TYPOlight Open Source CMS.
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, please visit the Free
* Software Foundation website at <http://www.gnu.org/licenses/>.
*
* PHP version 5
* @copyright 2012
* @author maffy (Matthias Reichert)
* @package wanderwege
* @license GNU/LGPL
* @filesource
*/
/**
* Table tl_gpx_tracks
*/
$GLOBALS['TL_DCA']['tl_gpx_tracks'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table',
'table' => 'tl_gpx_tracks',
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 1,
'fields' => array('title'),
'flag' => 1,
'headerFields' => array('title'),
'panelLayout' => 'search,limit',
'child_record_callback' => array('tl_gpx_tracks', 'title')
),
'global_operations' => array
(
'all' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();"'
)
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif'
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
),
'show' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
// Palettes
'palettes' => array
(
'__selector__' => array(''),
'default' => '{Allgemeine Infos},title;{GPXFile},Datei auswählen;{Kommentar:hide},Beschreibung'
),
// Fields
'fields' => array
(
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['title'],
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>64)
),
'Datei auswählen' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['gpxfile'],
'inputType' => 'fileTree',
'eval' => array('mandatory'=>false, 'files'=>true, 'fieldType'=>'radio',
'filesOnly' => true, 'extensions' => 'gpx', 'path' => 'tl_files/gpxviewer/')
),
'Beschreibung' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['beschreibung'],
'inputType' => 'textarea',
'eval' => array('rte'=>'tinyFlash')
)
)
)
?>
-
Ich habe gerade keine spontane Idee, außer das der Config Eintrag table unnötig ist.
Ich empfehle dir aber mal, die hier zu schauen:
http://www.youtube.com/playlist?list=PL02DE9846C628F23D
-
Moin,
also ich hab mir deine config mal angeschaut.
Sind ein paar Kleinigkeiten drin:
- unter "config" der "table"-Eintrag ist unnötig
- nach "list ... sorting" fehlt der "label"-Eintrag (für die Tabelle)
- unter "fields" muss das Feld für die Datei "gpxfile" heißen ... "Datei auswählen" kommt dann per Übersetzung ran
Also ungefähr so:
PHP-Code:
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
/**
* Contao Open Source CMS
* Copyright (C) 2005-2011 Leo Feyer
*
* Formerly known as TYPOlight Open Source CMS.
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, please visit the Free
* Software Foundation website at <http://www.gnu.org/licenses/>.
*
* PHP version 5
* @copyright 2012
* @author maffy (Matthias Reichert)
* @package wanderwege
* @license GNU/LGPL
* @filesource
*/
/**
* Table tl_gpx_tracks
*/
$GLOBALS['TL_DCA']['tl_gpx_tracks'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table'
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 1,
'fields' => array('title'),
'flag' => 1,
'panelLayout' => 'search,limit'
),
'label' => array
(
'fields' => array('title'),
),
'global_operations' => array
(
'all' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['all'],
'href' => 'act=select',
'class' => 'header_edit_all',
'attributes' => 'onclick="Backend.getScrollOffset();"'
)
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif'
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
),
'show' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['show'],
'href' => 'act=show',
'icon' => 'show.gif'
)
)
),
// Palettes
'palettes' => array
(
'__selector__' => array(''),
'default' => '{common_legend},title;{file_legend},gpxfile;{comment_legend:hide},beschreibung'
),
// Fields
'fields' => array
(
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['title'],
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>64)
),
'gpxfile' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['gpxfile'],
'inputType' => 'fileTree',
'eval' => array('mandatory'=>false, 'files'=>true, 'fieldType'=>'radio', 'filesOnly' => true, 'extensions' => 'gpx', 'path' => 'tl_files/gpxviewer')
),
'beschreibung' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['beschreibung'],
'inputType' => 'textarea',
'eval' => array('rte'=>'tinyFlash')
)
)
);
?>
Grüße, Cliff
P.S. ich würde empfehlen das Feld "beschreibung" in "description" umzubennen ... dann ist alles einheitlich in englisch
P.P.S glaube tinyFlash wird eher nicht mehr verwendet, tinyMCE ist da sicher die bessere Wahl ;-)
-
Danke, ich habe den Code aus dem CD Verwaltungs Tutorial rauskopiert bzw. durch den Modul Creator automatisch erstellen lassen.
Wo finde ich eine Anleitung bzw Beschreibung für die weiteren möglichen Felder.
Z.B wie eine Auswahlliste für Kategorien erstellt werden kann. und die Daten der Liste aus einer weiteren DB Tabelle eingelesen werden kann.
Mfg Maffy
-
Ja,
also am Besten dem Link von Tril folgen und dir die Screencasts alle anschauen ... kann ich nur empfehlen, da geht auch bei nem versierten Crack die ein oder andere Lampe noch an :rolleyes:
Als nächstes ist dann das Contao Open Source CMS Entwicklerhandbuch dran.
Und dann folgen intensive Code Studien ;) ... was meist richtig viel bringt, wenn es nicht blos kopiert wird!
Stichworte für Auswahllisten sind: select, options, option_callback, reference, foreignKey ....
Grüße, Cliff