Hi ChronoEngine,
I'm new to CC V5 & have a (slightly) unique requirement.
I use a J2.5 app called 'Form2content' (F2C) in the Frontend to allow Users to create & submit formatted articles.
F2C creates its own 'Articles' in db table '#__fc2_form' with a published 'state' column (Default is '0' = Unpublished) & in sync creates an actual Joomla Article in '#__content' with its published 'state' also set to '0' = Unpublished' then dumps 'Smarty Templated' content into the actual Joomla article.
The x-ref between the two is 'reference_id' in '#__f2c_form' & 'id' in '#__content'.
To retain formatting, article editing has to be done in via F2C. On 'Save' after editing F2C overwrites the Joomla article with new formatted content.
On my site i'm using CC V5 to list Unpublished F2C articles (#__f2c_form' 'state = 0'). 'Editors' review each article using CC V5 'Button' to call 'F2C Smarty Template & contents', he/she reviews Article & saves - works fine. Next step for 'Editors' is to 'Publish' that Article.
I have used 'Toogle' on '#__f2c_form.state' to switch F2C article 'state' to 'Publised' ('1') - that also works fine BUT of course Joomla article '#__content.state' is not changed - no auto sync between the two! I need to update the 'state' of both the F2C & Joomla Articles simultaneously.
As 'Toogle' can only perform one action, my thinking was to replace 'Toogle' with a 'Button' that calls a MySQL Update query (in fact 2 querys, one to update '#__f2c_form.state' & one to update '#__content.state'. Not sure how to write the query/s or where to put them or how to add a 'Button-OnClick' event ! I thought the query/s might be as follows :
In my case CC V5 'Connection name' = 'unpubf2c' & 'Model title' = 'f2carticles' :
// Update joomla article query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Fields to update in joomla #__content table.
$fields = array(
$db->quoteName('state') . ' = 1'
);
// Conditions for which records should be updated : 'id' = 'id' col in #__content
$conditions = array(
$db->quoteName('id') . ' = {f2carticles.reference_id}',
);
$query->update($db->quoteName('#__content'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
// Update f2c article query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Fields to update in #__f2c_form table.
$fields = array(
$db->quoteName('state') . ' = 1'
);
// Conditions for which records should be updated : 'reference_id' = 'reference_id' col in #__f2c_form
$conditions = array(
$db->quoteName('reference_id') . ' = {f2carticles.reference_id}',
);
$query->update($db->quoteName('#__f2c_form'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
All advice most welcome ! Cheers - Paul Zero.
I'm new to CC V5 & have a (slightly) unique requirement.
I use a J2.5 app called 'Form2content' (F2C) in the Frontend to allow Users to create & submit formatted articles.
F2C creates its own 'Articles' in db table '#__fc2_form' with a published 'state' column (Default is '0' = Unpublished) & in sync creates an actual Joomla Article in '#__content' with its published 'state' also set to '0' = Unpublished' then dumps 'Smarty Templated' content into the actual Joomla article.
The x-ref between the two is 'reference_id' in '#__f2c_form' & 'id' in '#__content'.
To retain formatting, article editing has to be done in via F2C. On 'Save' after editing F2C overwrites the Joomla article with new formatted content.
On my site i'm using CC V5 to list Unpublished F2C articles (#__f2c_form' 'state = 0'). 'Editors' review each article using CC V5 'Button' to call 'F2C Smarty Template & contents', he/she reviews Article & saves - works fine. Next step for 'Editors' is to 'Publish' that Article.
I have used 'Toogle' on '#__f2c_form.state' to switch F2C article 'state' to 'Publised' ('1') - that also works fine BUT of course Joomla article '#__content.state' is not changed - no auto sync between the two! I need to update the 'state' of both the F2C & Joomla Articles simultaneously.
As 'Toogle' can only perform one action, my thinking was to replace 'Toogle' with a 'Button' that calls a MySQL Update query (in fact 2 querys, one to update '#__f2c_form.state' & one to update '#__content.state'. Not sure how to write the query/s or where to put them or how to add a 'Button-OnClick' event ! I thought the query/s might be as follows :
In my case CC V5 'Connection name' = 'unpubf2c' & 'Model title' = 'f2carticles' :
// Update joomla article query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Fields to update in joomla #__content table.
$fields = array(
$db->quoteName('state') . ' = 1'
);
// Conditions for which records should be updated : 'id' = 'id' col in #__content
$conditions = array(
$db->quoteName('id') . ' = {f2carticles.reference_id}',
);
$query->update($db->quoteName('#__content'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
// Update f2c article query
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Fields to update in #__f2c_form table.
$fields = array(
$db->quoteName('state') . ' = 1'
);
// Conditions for which records should be updated : 'reference_id' = 'reference_id' col in #__f2c_form
$conditions = array(
$db->quoteName('reference_id') . ' = {f2carticles.reference_id}',
);
$query->update($db->quoteName('#__f2c_form'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
All advice most welcome ! Cheers - Paul Zero.