Hi guys,
I've got a problem. I am trying to create an extension that copies a template from the module folder(s). (Like the standard tpl_editor), but also put information in the database, for easier sorting and filtering of templates. But it seems that when I call the function "copyTemplates" with "onsubmit_callback" it doesn't add the field to the database. Does anyone know how I can call a function with "onsubmit_callback" and call the standard function for adding the fields to the database.
My thanks.
My database table
Code:
--
-- Table `tl_tplsorter`
--
CREATE TABLE `tl_tplsorter` (
`id` int(10) unsigned NOT NULL auto_increment,
`tstamp` int(10) unsigned NOT NULL default '0',
`templateName` varchar(60) NOT NULL default '',
`templateFile` varchar(80) NOT NULL default '',
`templateCategory` varchar(60) NOT NULL default '',
`templateDescr` varchar(120) NOT NULL default '',
PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
copyTemplates function
Code:
public function copyTemplates()
{
// Copy an existing template
if (file_exists(TL_ROOT . '/system/modules/' . $this->Input->post('templateFile')))
{
$strOriginal = preg_replace('#.*/(.*)$#', '$1', $this->Input->post('templateFile'));
if (file_exists(TL_ROOT . '/templates/' . $strOriginal))
{
$_SESSION['TL_ERROR'][] = sprintf($GLOBALS['TL_LANG']['tl_tplsorter']['exists'], $strOriginal);
$this->reload();
}
$this->import('Files');
if ($this->Files->copy('system/modules/' . $this->Input->post('templateFile'), 'templates/' . $strOriginal))
{
$this->redirect($this->getReferer());
}
$this->reload();
}
}
my config array
Code:
'config' => array
(
'dataContainer' => 'Table',
'enableVersioning' => true,
'onsubmit_callback' => array(array('tl_tplsorter','copyTemplates'))
),
Bookmarks