Welcome, Guest
Username: Password: Remember me

TOPIC: Module for singular view with fly

Module for singular view with fly 31 Aug 2016 02:33 #14501

  • rtate2005
  • rtate2005's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Karma: 0
Is there a why to display a singular view including the fly

data. I see the following code example but I can't figure out how to target a certain singular view and include any fly data.


$model = CkJModel::getInstance('singular_model_name', 'MycomponentModel');
$model->setState( .... ); // TODO: Set any state variables you want to use
$item = $model->getItem();
The administrator has disabled public write access.

Module for singular view with fly 31 Aug 2016 07:47 #14502

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3695
  • Thank you received: 971
  • Karma: 140
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.
Coding is now a piece of cake
Last Edit: 31 Aug 2016 07:50 by admin.
The administrator has disabled public write access.

Module for singular view with fly 02 Sep 2016 04:54 #14506

  • rtate2005
  • rtate2005's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Karma: 0
Ok, thanks what if I just wanted to display the item instead of a collect inside a module.
The administrator has disabled public write access.
Time to create page: 0.054 seconds

Get Started