You need to play with populateQuery() in your concerned Item model.
Inside the "switch" query, you can modify or add a context page.
Contexts are simply 'presets' for the SQL query. They are not limited to anything. Be free. By default, Cook create a different context for every layout.
The presets are more used for "SELECT" fields
Additionally, you can create states vars giving the name you want, when a particular feature is applied to the model.
State vars are more used for cross-views features of the SQL query.
A simple and good example can be for loading a row based on a FK value (user)
$model->setSate('account.user', 'auto');
And in the 'Account' model : populateQuery()
if ($this->getState('account.user' == 'auto')
{
// Our example load the item based on the FK (user), instead of the Pk id.
$query->where('a.user = ' . (int) JFactory::getUser()->id);
}
else
{
// Our example need to avoid this original code, searching the row
$query->where('a.id = ' . (int) $pk);
}
Hope it helps.
Contexts => For pages, or Ajax, CLI, exports... (mostly used for 'SELECT', 'JOIN')
States vars => For Features (ACL, Searches, ...) (mostly used for 'WHERE', 'JOIN', )
Context is stored in the 'context' state var, means that the context is a state var itself
You are 100% to do what you want with them.