Hi all
I use the Joomla-function--Submit Article to insert new items.
How do I insert a new image in the table content-images-image_intro?
Thanks and sorry for my bad english
I use the Joomla-function--Submit Article to insert new items.
How do I insert a new image in the table content-images-image_intro?
Thanks and sorry for my bad english
Ok
Using chronoform for posting new items.
Submit event on the form I insert "Joomla-function - Submit Article".
I want to insert the image in the database, the table content in the column images - image_intro
is it possible?
thanks
Using chronoform for posting new items.
Submit event on the form I insert "Joomla-function - Submit Article".
I want to insert the image in the database, the table content in the column images - image_intro
is it possible?
thanks
Hi addviser,
Hmmm . . . I've never used that column. It looks as though it is a jSON encoded array so I think that you'd need to read the existing value, convert that to an array; update the array with any new values; re-encode it back to JSON again and then let the resulting value be saved to the database. Here's some code that should get you started - not tested and will need debugging. It needs to go into a custom code action before the Submit Article action and assumes that the article id is available as $form->data['art_id']:
Bob
Hmmm . . . I've never used that column. It looks as though it is a jSON encoded array so I think that you'd need to read the existing value, convert that to an array; update the array with any new values; re-encode it back to JSON again and then let the resulting value be saved to the database. Here's some code that should get you started - not tested and will need debugging. It needs to go into a custom code action before the Submit Article action and assumes that the article id is available as $form->data['art_id']:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT `images`
FROM `#__content`
WHERE `id` = '{$form->data['art_id']}' ;
";
$db->setQuery($query);
$images = $db->loadResult();
$images = json_decode($images);
$images['image_intro'] = 'some image name';
$images = json_encode($images);
$form->data['images'] = $images;
?>
Bob
This topic is locked and no more replies can be posted.