Hi Dinhtrung,
In the latest version of this extension it is not necessarily needed anymore to manually create the data file. The data file will be automatically created when some data is getting saved to the model. In the very first version it was indeed needed to manually create the data file, but I haven’t changed the “manual” yet.
And to answer your second question, the array structure must be there to define how the data file is structured. The array structure must be just like that the keys of arrayStructure() are the actual keys in the data file, and the values of array_structure() are the unique corresponding attribute names of the model.
So if your data file is something like this:
array(
'name' => 'Aasdd asd ads',
'description' => 'Sample bla',
'detail' => '',
);
Then your arrayStructure() should be like this:
public function arrayStructure()
{
array(
'name' => 'name',
'description' => 'description',
'detail' => 'detail',
);
}
In this case, the element ‘name’ inside the data file can be accessed by calling $model->name. In your case you can just use the same attribute names as the key names inside the data file.
To make it something more clear, if your arrayStructure() is like this:
public function arrayStructure()
{
array(
'name' => 'name_new',
'description' => 'description_new',
'detail' => 'detail_new',
);
}
Then you can for example access the element ‘name’ inside the data file by calling $model->name_new.
I made the model work like this, because then the developer can use associative array data structures, like this:
public function arrayStructure()
{
array(
'name' => array(
'old' => 'name_old',
'new' => 'name_new',
),
'description' => 'description',
'detail' => 'detail',
);
}
In this example, you can access array[‘name’][‘old’] by calling $model->name_old and array[‘name’][‘new’] by calling $model->name_new.
I understand that the arrayStructure() can be very confusing and I hope this explaination helps you a bit. Feel free to ask more questions.
Instinct