Welcome, Guest
Username: Password: Remember me

TOPIC: Get state of a filter

Get state of a filter 15 Sep 2016 12:54 #14537

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 16
I should be able to do this, but lack of sleep is taking its toll

I have a field on a grid view that i ONLY want to show if someone is looking at grid with a filter_published = 2 (ie looking at archived records)

I though the filters were passed silently through POST but I suspect i need to use a STATE call

So in essence (making this stuff up) something like
<?php if(getState::(filter.published) == 2) { ?>
<td>STUFF YOU CAN SEE IF ARCHIVED</td>
<?php }; ?>
Morgan Leecy MCSE

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

Get state of a filter 15 Sep 2016 18:46 #14539

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
In a grid view you can do:
<?php if ($this->state->get('filter.published',0) == 2 ) : ?>
<td>STUFF YOU CAN SEE IF ARCHIVED</td>
<?php }; ?>

I have used it (also for hiding/showing columns)
Last Edit: 15 Sep 2016 18:47 by Romkabouter.
The administrator has disabled public write access.

Get state of a filter 15 Sep 2016 21:13 #14540

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 16
SO CLOSE!!!

Thanks as always
Morgan Leecy MCSE

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

Get state of a filter 16 Sep 2016 10:32 #14541

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
$model->getState('filter.xxxx')

EDIT : Better to use $model, because you can have various models instanced.
Instead, $this->state is only based on the page default model. (works also)
Coding is now a piece of cake
Last Edit: 16 Sep 2016 10:34 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: organicwebs

Get state of a filter 16 Sep 2016 10:40 #14542

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Good addition, I was assuming the page default model was needed :)
The administrator has disabled public write access.

Get state of a filter 16 Sep 2016 10:42 #14543

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Also $this->state works only in the view, instead the $model is cross application.
Always be careful with states that you are under the same context.

The states vars are a 2 dimentional matrix :
Unlimited states vars X unlimited contexts
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.103 seconds

Get Started