This topic is locked

ListOnload Event BEFORE SQL query

7/27/2007 9:35:08 AM
Suggestions
S
smaris author

Hi,
In many posts, users asks for the possibilty to add an extra filter on the SQL statement before the list is generated.
The clean solution to do this in the 'OnLoad' event. The current ListOnLoad event is triggered in the Smarty template, which is processed AFTER the main SQL query. In this way you can only change the view of the result list, but not the SQL query itself (or maybe rerunning it in the event code...?). tested this in a 3.1 project, but I can see that it is invoked at the same place in 4.1 templates.
Doing the modification in the _list.php code (which is now most of the time suggested by support) has a major negative side-effect: the code is not maintained after rebuilding the project.
Anyhow, a more usefull solution would be if either the Onload event is triggered from the PHP code before the SQL query is executed, or to have an extra event at this code part. I can image that there are pro and contras for both posibilities...
Stefan

S
smaris author 7/27/2007

just forget my question.... I haven't looked at the 4.1 specs properly...
Just want to notice that using the AddWhere in BeforeQuery does not take the 'order' clause in account (yet)... 'Group by' is catched.. need a bug fix for 'Order by' I suppose...
Stefan

Sergey Kornilov admin 7/27/2007

Stefan,
thanks for pointing me to this. We'll fix this in the next update.