The best to maintain filter

webcrea 25 Jun, 2017
Hi,

All is in title... I think i have to use save to session but how to make the difference if first request? with switch?

thanks
Max_admin 25 Jun, 2017
Hi Christophe,

Let's say the filter submits the data to the "index" event, then in the "index" event call a switch function, the data provider should be:

{data.empty:filter_field_name}

The values setup:

false:{session.set:my_filter$(data:filter_field_name)}
true:{session.clear:my_filter}

And the where conditions should be actually set to red from the session variable.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 25 Jun, 2017
Hi Max,

filter is a dropdown named select_sg

values selected
{session:filter_sg}

in read_data conditions fonds.sg_id:{session:filter_sg}/-

the switch switch_filter_sg
{data.empty:select_sg}

false:{session.set:filter_sg$(data:select_sg)}
true:{session.clear:filter_sg}

in the index and view views I put <p>Filtre {session:filter_sg}</p>

the filter_sg is correctly passed to the view, and when i click to go back to the list(index), the filter_sg is always informed but the dropdown and list are not up to date with the filter_sg

Something miss?

I think I need a second witch on session var for the true result of the first ?

Regards
Max_admin 26 Jun, 2017
Hi Christophe,

The switch function is called BEFORE the read data and the listing/filter view in the event ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 26 Jun, 2017
Hi Max,

Yes and yes

This is private content



Regards
Max_admin 30 Jun, 2017
Hi Christophe,

It looks like the switch function will not be enough here, a PHP function will be needed to check if the "data" value of "select_sg" is present and is empty to clear it.

if(isset($this->data["select_sg"])){
if(empty($this->data["select_sg"])){
\GApp::session()->clear("filter_sg");
}else{
\GApp::session()->set("filter_sg", $this->data["select_sg"]);
}
}


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 30 Jun, 2017
Hello Max,

I put it just before the switch in index view and nothing. The filter_sg is still empty

Regards
Max_admin 02 Jul, 2017
Hi Christophe,

Well, the code had something wrong, I fixed it now, please try it again!

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webcrea 02 Jul, 2017
Hi Max,

Sorry I saw the fixed code but on the front, I filtered by sg and go into a fiche, the filter is still right. Then i go back by clicking on "Tableau" and no filter apply!

I have this error
Parse error: syntax error, unexpected ')' in /home/.../libraries/cegcore2/admin/extensions/chronofc/functions/php/php_output.php(6) : eval()'d code on line 2

Thanks
Regards
This topic is locked and no more replies can be posted.