use alias and enclosure from frontend
Hi,
I'm trying to create something for a web based application thaht needs to insert new records in the tl_news table of contao from a front-end form.
Before coding the form, I have tested manually how to insert a new record using phpmyadmin. I have some errors with the alias and enclosure fields.
how can I create a new record in that table from frontend ? Is there some functions to generate automatically value for that fields ?
Thanks in advance for your helps.
Re: use alias and enclosure from frontend
Re: use alias and enclosure from frontend
Here are the logs from phpmyadmin:
Code:
requête SQL: Modifier
INSERT INTO `contao`.`tl_news` (
`id` ,
`pid` ,
`tstamp` ,
`headline` ,
`alias` ,
`author` ,
`date` ,
`time` ,
`subheadline` ,
`teaser` ,
`text` ,
`addImage` ,
`singleSRC` ,
`alt` ,
`size` ,
`imagemargin` ,
`imageUrl` ,
`fullsize` ,
`caption` ,
`floating` ,
`addEnclosure` ,
`enclosure` ,
`source` ,
`jumpTo` ,
`articleId` ,
`url` ,
`target` ,
`cssClass` ,
`noComments` ,
`featured` ,
`published` ,
`start` ,
`stop`
)
VALUES (
NULL , '8', '0', '', UNHEX( '' ) , '2', '0', '0', '', NULL , NULL , '', '', '', '', '', '', '', '', '', '', UNHEX( ) , 'default', '0', '0', '', '', '', '', '', '1', '', ''
)
MySQL a répondu:Documentation
#1582 - Incorrect parameter count in the call to native function 'UNHEX'
Re: use alias and enclosure from frontend
the problem is related to phpmyadmin that doesn't check the input you provide
it has nothing to do with the alias and enclosure fields.
however:
you can create the alias with the following code
Code:
$alias = standardize($newsTitle);
where "standardize" is a function provided by Contao and $newsTitle is the value of the news title coming from your form.
enclosure should contain a serialize()'d array of files path e.g.
Code:
$arrAttachment = array('tl_files/path/to/file1', 'tl_files/path/to/file2');
$enclosure = serialize($arrAttachment);
please note that if you need to show attachment using standard news frontend modules you *must* set the addEnclosure field to 1
Re: use alias and enclosure from frontend