Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] forking populateState does not work

forking populateState does not work 14 Jun 2015 21:24 #13264

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 16
I though I was going mad, but been able to replicate this in several models now.

Basically I wanted to use a different version of

parent::populateState('a.ordering', 'asc');

to set the default filters in a view. i.e in this case

parent::populateState('a.creation_date', 'desc');

I have already FORK'ed the model for prepareQuery and that works fine.. however, any changes I was making to the FORK'ed populateState was not working.

I then altered the core populateState in the appropriate model and that worked.

So unless I am doing something extremely stupid, populateState cannot be forked in a model, even though everything else can
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

forking populateState does not work 13 Jul 2015 09:17 #13332

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
I do not know what code you created, but if you use parent in your fork, maybe this is your problem?
www.j-cook.pro/index.php/f/forks

parent, self

The fork feature has a limitation with the parent and self keywords.
In facts, the parent of your forked class is the original one, not its real parent.
The self keyword call the original class, so in your fork it becomes parent.

Some trick functions like JView::_parentDisplay() permit to avoid this problem.

For example when you override a view file, instead of calling :

parent::display(); //Infinite loop
Replace by one of the following possibilities

$this->_parentDisplay();
self::_parentDisplay(); // Static call
return self::_parentDisplay(); //Static call with returning value
The administrator has disabled public write access.
The following user(s) said Thank You: admin

forking populateState does not work 24 Sep 2015 18:17 #13496

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I have fixed the function, so you can now achieve it.

When it receives ordering & direction from parent, it uses it in priority.

By the way, I also cleaned the item model which should not be concerned by this ordering & direction.
So I removed the parameters in the populateState() item model.

Hope it helps.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.095 seconds

Get Started