3

I modified the publish-function of my sub-controller as follows

    /**
     * publish function.
     * 
     * @access public
     * @return void
     */
    public function publish()
    {
        $app                                    =   JFactory::getApplication();
        $jinput                                 =   JFactory::getApplication()->input;
        $ids                                    =   $jinput->get('cid', '', 'array');
        $task                                   =   $this->getTask();

        foreach($ids as $id)
        {
            // do fancy stuff
        }

    }

Now I really would like to change the status of some items (-> $ids) via an CLI-script.

Is it possible to call this controller, get the method "publish" and submit a set of ids and, assigned to this, a task (publish, unpublish, trash, ...)?

1

Yes, it is possible, but your have to create your own CLI script to translate the command line to the Joomla API command. For example:

  • To receive a list of IDs (comma separated) from an argument
  • Initialize JInput,
  • and send it to your controller.

You can check any of the cli/ script to create your own script.

1

Recently i made a component when i change the o publish status via Ajax request.

I made a method setPublish($id, $status) on model, and two methods on my controller:

public function setPublishTrue(){
   $data = JRequest::get('post'); //get the item id via post
   $model = $this->getModel('Promocaos');
   $model->setPublish($data['id'], 1);

} 

The ajax request:

        var formdata = $("#form-" + this.id).serialize();

        if(state){
            jQuery.ajax({
            type: "POST",
            dataType: "json",
            timeout: 6000,
            url: "index.php?option=com_mycomponent&task=setPublishTrue&controller=mycontroller",
            data: formdata,
            processData: false
        });

Then, i can change the status via Ajax requests

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.