Ich habe mir nun auf Basis eines Tutorials ein kleines BE und FE Modul für meine Wanderwege geschrieben.
Dort kann ich nun Datesätze anlegen und bearbeiten etc.
Leider steht in diesem alten Tutorial für Firmenfarzeuge nicht drinnen, wie ich die Daten aus der Datenbank in das Template einfügen kann.
Da steht nur wie ich das ohne Datenbank statisch Eintrage. Was aber soweit auch im FE angezeigt wird.
Ich habe eine SQL Tabelle in der alle Daten für die Wanderung drinnen stehen.
Code:
--
-- Table `tl_gpx_tracks`
--
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',
`thema` varchar(125) NOT NULL default '',
`title` varchar(125) NOT NULL default '',
`description` 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;
Leider finde ich keine Informationen wie ich nun die Datenbank auswählen kann,
und die Daten als Liste in einem template schreiben kann.
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 maffylein (Matthias Reichert)
* @package wanderwege
* @license GNU/LGPL
* @filesource
*/
/**
* Class gpxverwaltung
*
* @copyright 2012
* @author maffylein (Matthias Reichert)
* @package Controller
*/
// Demo Bsp.
class gpxverwaltung extends Module
{
protected $strTemplate = 'gpxtrack_list';
protected function compile()
{
$data = array();
$data['companyCar']['producer'] = 'Audi';
$data['companyCar']['model'] = 'A5';
$data['companyCar']['owner']['name'] = 'Max Mustermann';
$data['companyCar']['owner']['department'] = 'Marketing';
$this->Template->data = $data;
}
}
?>
Lesezeichen