How to create a custom action for module in cms?

I have a module of documents which has information saved in database, I want to create an action like VIEW, DELETE to create a PDF with the data I have saved, I want the admin to be able to click button and create pdf of data of the row in the list of entries of module, like we can select DELETE to delete that entry.

Comments

  • You can do something like the following in your module's config in MY_fuel_modules.php:

    ...
    'table_actions' => array('VIEW', 'EDIT', 'PDF' => array('func' => function($fields){
            $CI =& get_instance();
            if ($CI->fuel->auth->has_permission('documents/pdf'))
            {
                return '<a href="' . fuel_url('documents/pdf/' . $fields['id']) . '">VIEW</a>';
            }
        }), 'DELETE'),
    ...
    
  • Okay, I want to use the TCPDF to generate a PDF here can it be done too? I mean the way I have integrated it is through library, is it possible to do all sorts of controller things here? like loading library and then calling its function?

  • Yes... FUEL is just a layer on top of CI.

  • Thanks, I have created a function in controller and called the layout of pdf from a cms page and simply pointed this link to that function.

Sign In or Register to comment.