Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

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();

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

Last edit: by admin.

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

Ok, thanks what if I just wanted to display the item instead of a collect inside a module.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.082 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started