AnsweredAssumed Answered

Custom Module With External Data

Question asked by kelaskakap on Jan 4, 2016
Latest reply on Jan 4, 2016 by kelaskakap

So, I'm building custom module from module builder and trying to customize it. I build this module because I need an interface to interact with an API service I'm deal with. I need to get data from API, post, delete and update data to API service. So basically this module is just an interface which connected to the API service. for now I still do not need CRUD to the module's table.

 

 

For example, I request data from API service endpoint, and got result (json format, and decoded) . I do it from the controller (I've created).

$data = array (
  'rows' =>
  array (
    stdClass::__set_state(array(
       'id' => 1,
       'name' => 'jessica',
       'age' => '',
       'address' => 'yogyakarta'
      array (
      ),
    )),
    stdClass::__set_state(array(
       'id' => 2,
       'name' => 'tania',
       'age' => '',
       'address' => 'surabaya'
      array (
      ),
    )),
    stdClass::__set_state(array(
       'id' => 3,
       'name' => 'amanda',
       'age' => '',
       'address' => 'jakarta'
      array (
      ),
    )),
  ),
  'current_page' => 1,
  'prev' => 0,
  'next' => 2,
  'last' => 1,
)

How to view the array above into the view list? is there any way to inject the data to the bean?

 

 

I've create custom fields for this :

#custom/Extension/modules/MyStudent/Ext/Language/en_us._custom_fields.php
$mod_strings['LBL_NAME'] = 'Name';
$mod_strings['LBL_AGE'] = 'Age';
$mod_strings['LBL_ADDR'] = 'Address';

#custom/Extension/modules/MyStudent/Ext/Vardefs/custom_fields.php
$dictionary["MyStudent"]["fields"]["s_name"] = array(
    'required' => false,
    'name' => 's_name',
    'vname' => 'LBL_NAME',
    'type' => 'varchar',
    'source' => 'non-db',
    'studio' => 'visible',
);


$dictionary["MyStudent"]["fields"]["s_age"] = array(
    'required' => false,
    'name' => 's_age',
    'vname' => 'LBL_AGE',
    'type' => 'varchar',
    'source' => 'non-db',
    'studio' => 'visible',
);
$dictionary["MyStudent"]["fields"]['s_address'] = array(
    'required' => false,
    'name' => 's_address',
    'vname' => 'LBL_ADDR',
    'type' => 'varchar',
    'source' => 'non-db',
    'studio' => 'visible',
);

and then do quick repair and rebuild. and use the fields above from studio, drag & drop to the layout listview.

 

 

How to inject data I got from API service into the bean and then view into viewlist? what and where should I override ?

 

 

Thank you.

Outcomes