Hallo liebe Community,
Ich versuche gerade in einer eignen Erweiterung die toogle Funktion zum ein und ausblenden zu implementieren.
Leider scheitere ich gerade:
Ich habe zuerst das zusätziche Feld in der Datenbank angelegt:
Code:
$GLOBALS['TL_DCA']['tl_produktewebsite']['fields']['published'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_produktewebsite']['published'],
'exclude' => true,
'filter' => true,
'inputType' => 'checkbox',
'sql' => "char(1) NOT NULL default ''"
);
Das funktioniert natürlich ohne Probleme, danach habe ich die toogle Funktion in der DCA eingefügt:
PHP-Code:
$GLOBALS['TL_DCA']['tl_produktewebsite']['list']['operations']['toggle'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_example']['toggle'],
'icon' => 'visible.gif',
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
'button_callback' => array('tl_produktewebsite', 'toggleIcon')
);
Anschliessend habe ich unter system/meineerweiterung/einen Ordner classes angelegt und tl_produktewebsite.php mit folgendem Inhalt:
PHP-Code:
<?php
class tl_produktewebsite
{
public function toggleIcon($row, $href, $label, $title, $icon, $attributes)
{
$this->import('BackendUser', 'User');
if (strlen($this->Input->get('tid')))
{
$this->toggleVisibility($this->Input->get('tid'), ($this->Input->get('state') == 0));
$this->redirect($this->getReferer());
}
// Check permissions AFTER checking the tid, so hacking attempts are logged
if (!$this->User->isAdmin && !$this->User->hasAccess('tl_example::published', 'alexf'))
{
return '';
}
$href .= '&id='.$this->Input->get('id').'&tid='.$row['id'].'&state='.$row[''];
if (!$row['published'])
{
$icon = 'invisible.gif';
}
return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.$this->generateImage($icon, $label).'</a> ';
}
}
Anschliessnd erhalte ich nun folgenden Fehler:
Attempted to load class "tl_produktewebsite" from the global namespace. Did you forget a "use" statement?
Zusätzlich gibt es noch die Datei tl_produktwebsite.php im root derErweiterung mit diesem Inhalt:
PHP-Code:
<?php
if (!defined('TL_ROOT')) die('You can not access this file directly!');
class tl_produktewebsite extends Backend
{
public function saveFile($value) {
if (version_compare(VERSION,'3.2','>=')) {
$uuid = StringUtil::binToUuid($value);
$objFile = FilesModel::findByUuid($uuid);
$value = $objFile->path;
}
return $value;
}
public function loadFile($value) {
if (version_compare(VERSION,'3.2','>=')) {
$objFile = FilesModel::findByPath($value);
$value = $objFile->uuid;
}
return $value;
}
}
?>
Die autoload enthält folgenden Inhalt:
PHP-Code:
<?php
/**
* Back end modules
*/
$GLOBALS['BE_MOD']['content']['JK produktewebsite'] = array(
'tables' => array('tl_produktewebsite'),
'icon' => 'system/modules/produktewebsite/assets/images/screencast.png'
);
/**
* Front end modules
*/
$GLOBALS['FE_MOD']['produktewebsite'] = array
(
'produktewebsite' => 'ModuleProduktewebsite',
);
autoload.php
PHP-Code:
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2014 Leo Feyer
*
* @package Process-form-messe
* @link https://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Register the classes
ClassLoader::addNamespaces(array
(
'ModuleProduktewebsite' => 'system/modules/produktewebsite/modules/ModuleProduktewebsite.php',
));
ClassLoader::addClasses(array
(
'tl_produktewebsite' => 'system/modules/produktewebsite/tl_produktewebsite.php',
));
TemplateLoader::addFiles(array
(
'mod_produktewebsite' => 'system/modules/produktewebsite/templates',
));
<?php
*/
ClassLoader::addClasses(array
(
// Modules
'ModuleProduktewebsite' => 'system/modules/produktewebsite/modules/ModuleProduktewebsite.php',
'tl_produktewebsite' => 'system/modules/produktewebsite/classes/tl_produktewebsite.php',
));
/**
* Register the templates
*/
TemplateLoader::addFiles(array
(
'mod_produktewebsite' => 'system/modules/produktewebsite/templates',
));
Wäre sehr dankbar wenn mir jemand kurz helfen konnte. Vielen Dank
Lesezeichen