I'm developing a small plugin for Joomla 3.x that adds a "Trash article" button when you're in Joomlas Frontend. See screenshot below.
https://i.stack.imgur.com/nlycx.jpg
Now I have this AJAX call that happens when you click on the list item.
Here's the code:
request = {
"option" : "com_ajax",
"plugin" : "deletearticle"
"data" : "test",
"format" : "raw"
};
$.ajax({
type : "POST",
data : request,
success: function (response) {
$("p:first").html("Data: " + response)
}
});
And the helper PHP file.
<?php
jimport('joomla.plugin.plugin');
class plgAjaxDeletearticle extends JPlugin
{
function onAjaxDeletearticle()
{
$controller = JControllerLegacy::getInstance('Content');
$controller->execute(JFactory::getApplication()->input->get('task'));
}
}
I'm right now doing work experience and I asked my mentor how I should change the article state to trashed. And he gave me the code inside the function and told me that I should be able to modify it in some way, so that the controller will execute a save function on the article.
I've tried and read up on this stuff but it doesn't seem to be all that well documented. Any help would be greatly appreciated as I'm not quite sure how I should proceed.
Thanks.