New keys for table schema

Posted on June 6, 2020

Releases Tutorials Updates

The table schema is used for a content type. It gives to the application the structure of the database table that stores the data. So the content administration page will be generated on its own and the content creators can manipulate the data with no further code. https://gila-cms.readthedocs.io/en/latest/schemas.html#table-schema

This keys are added in the update 1.14.1

extends

With extends key, a new content type can inherit another in order to creat easier an alternative version of the same table:

...
'extends'=>'core/tables/user.php',
'fields'=>[
  'address'=>[
    'type'=>meta
  ]
]

filter_owner

Now we can filter the results of an array and link the rows on a user based on the user id

...
'extends'=>'package/tables/movies.php',
'title'=>'My Movies',
'filter_owner'=>'user_id' # column name that stores the user id
...

The above example works like 'filters'=>['user_id'=>Session::userId()] but we dont need to add code in the array.

meta_table

Until now every meta field (a field that stores the data in a meta table) has to specify in with meta table is from. With meta-table we can set the table once for all the fields, and with metatype we set only the value of the key field:

#instead of this
...
'fields'=>[
  'phone'=>[
    'type'=>'meta',
    'mt'=>['usermeta', 'user_id', 'value'],
    'metatype'=>['vartype', 'phone']
  ]
]
...
#we can write this
...
'meta-table'=>['usermeta', 'user_id', 'vartype','value'],
# [<table>,<userId column>,<metaType column>, <metaValue colum>]
'fields'=>[
  'phone'=>[
    'type'=>'meta',
    'meta_key'=>'phone'
  ]
]
...

meta_key

The name of the metakey

 

Subscribe to our newsletter