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.057 seconds

Amazing Tool !
And only tool I know that allows complete Scaffolding in terms of component creation. It really saves loads of time (actually much more than that). Simple architecture enables quick and painless changes at any time. Code is clean and consintent. It's just... what's the word... neat! :) Great work! You should definetely try this one!

pi_wo (JED)
         

Get Started