Search for 'relation' in a fresh downloaded component, you will get all the functions involved.
Most are located in model superclass.
Not exhaustive (can be incomplete):
Declarations:
local var $relations in the model (cache var)
Functions:
newRelation()
hasMany()
hasOne()
belongsTo()
belongsToMany()
(This is the conventions names are inspired from Nicholas Dionysopoulos to keep same conventions than FOF, but also because they are good syntax)
prepareQueryRelations()
To get the relations maps :
$model->getRelation($name);
To populate a cross reference:
$model->loadRelation($name);
To save the relations:
$model->syncRelation($name, $values);
To implement it :
Override of ModelItem::save() in the superclass
Override of ModelList::__construct() in every list model (Relation definition)
Relation definition.
Cook Uses exactly the same than FOF, so when you build for FOF the component stay consistent.
See there for learning how to configure:
github.com/akeeba/fof/wiki/Model-relations
The only thing on top is the select[] array, wich defines the list of fields to include in the 'select' query.
Very usefull in our case. (the FIRST field name in select[] is took as default fallback when you do not specify in the caller)
Fields (model/fields)
- model.php
- relation.php
Note : loadXref() and updateXref() are deprecated (old system) Do not use them.
Views:
To load a cross reference, you NEED to call, in the view:
$model->loadRelation('myRelation');
AFTER $model->getItem(); or plural : $model->getItems();
Have a look how displayXxx() is written with that.
Hope it helps. It is difficult to remember it the whole thing.
Then see if you get PHP errors for missing some things (maybe your old version is missing other functions)