Hallo.
Ich habe nun ein BA Programmiert und einige Datensätze eingetragen so weit funktioniert das gut.
Wie kann ich nun ein eigenes Inhaltselement Programmieren, dann einen einzelnen Datensatz auswählen und diesen bei einem Artikel einfügen?
So sieht die Datei gpxverwaltung.php
Code:
class gpxverwaltung extends Module
{
/**
* Template
* @var string
*/
protected $strTemplate = 'gpxtracks';
}
class Content_Product extends ContentElement
{
protected $strTemplate = 'gpxtracks';
protected function compile()
{
}
}
So sieht die Config aus:
Code:
$GLOBALS['BE_MOD']['content']['Wanderwege'] = array
(
'tables' => array('tl_gpx_tracks'),
'icon' => 'system/modules/wanderwege/icons/wandern15px.gif'
);
/**
* Frontend Modules
*/
//Front-end
//CSS
$GLOBALS['TL_CSS'][] = 'system/modules/wanderwege/html/wanderwege.css';
//Javascript
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/wanderwege/html/wanderwege.js';
so sieht die sql aus:
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;
So sieht die dca -> tl_gpx_tracks.php aus:
Code:
/**
* 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' => '{Allgemeine Daten},thema,title;{GPX File},gpxfile;{Infotext:hide},description'
),
// Fields
'fields' => array
(
'title' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['title'],
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>125)
),
'thema' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['thema'],
'inputType' => 'text',
'search' => true,
'eval' => array('mandatory'=>true, 'maxlength'=>125)
),
'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')
),
'description' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_gpx_tracks']['description'],
'inputType' => 'textarea',
'eval' => array('rte'=>'tinyMCE')
)
)
);
so sieht das Template aus wo die Daten ausgibt:
wobei der Pfad zur GPX Datei automatisch eingetragen werden soll.
Der Titel und die Beschreibung sollen automatisch eingetragen werden.
Code:
<?php
$filename = 'tl_files/gpxviewer/fsw-etappe-1.gpx';
?>
<center>
<br /><br />
<div id="infobox">
<h1>Hier soll der Titel erscheinen</h1>
<p>Hier soll die Beschreibung erscheinen</P>
</div>
<div id="map" class="gpxview:<?PHP echo $filename?>:Oberflaeche" style="width:500px;height:225px;"><p>Zum Anzeigen der Karte wird Javascript benötigt.</p></div>
<br style="clear:both">
<div id="map_hp" style="width:500px;height:100px">
<noscript><p>Zum Anzeigen des Höhenprofils gegen den Weg wird Javascript benötigt.</p></noscript>
</div>
</center>
Lesezeichen