links-home and filters in url

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
jeannov
Posts: 11
Joined: 2015-04-01 17:14
Location: Trois-Rivieres,QC Canada

links-home and filters in url

Post by jeannov » 2015-05-02 15:08

Using AG 5.31 and learning PHP.

In links-home.php, I have this custom link:

$homeLinks[] = array(
'url' => 'jeantable_view.php?FilterAnd[1]=&FilterField[1]=4&FilterOperator[1]=<=>&FilterValue[1]=products', ...

with this filter, all records in jeantable are displayed.

Since everyone has to know the creator of each record, I have a field auto-filled with <%%creatorUsername%%>

With one click, I want to display all the records created/owned by the current signed in member.

I know $memberInfo is available with the global hook function login_ok(), getMemberInfo() could also be used, but where to put the code and how to insert the username of the current signed in member in this second part of the url ?

... &FilterAnd[2]=and&FilterField[2]=3&FilterOperator[2]=<=>&FilterValue[2]=member_username', ...

Any suggestion ?
Thanks

Jean

jeannov
Posts: 11
Joined: 2015-04-01 17:14
Location: Trois-Rivieres,QC Canada

Re: links-home and filters in url

Post by jeannov » 2015-05-03 13:55

Answering to myself.
Found in home.php where validation of $homeLinks are done, the value of &FilterValue[2] could be replaced by the signed in user.
Searching for a solution !

Jean

jeannov
Posts: 11
Joined: 2015-04-01 17:14
Location: Trois-Rivieres,QC Canada

Re: links-home and filters in url

Post by jeannov » 2015-05-04 18:58

Found my solution:

in hooks/_global.php, modify function login_ok

function login_ok($memberInfo, &$args){

$_SESSION['signinmember']=$memberInfo['username'];

return '';
}


in hooks/links-home.php, modify the value of FilterValue[2]


$homeLinks[] = array( ...

'url' => 'jeantable_view.php?FilterAnd[1]=&FilterField[1]=4&FilterOperator[1]=<=>&FilterValue[1]=products&FilterAnd[2]=and&FilterField[2]=3&FilterOperator[2]=<=>&FilterValue[2]='.$_SESSION['signinmember'],
...

If invoked when no one signed in, then only the first filter is executed.

Jean

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: links-home and filters in url

Post by patsd102 » 2015-05-04 21:41

Thanks for sharing Jean

Pat
23.17

jeannov
Posts: 11
Joined: 2015-04-01 17:14
Location: Trois-Rivieres,QC Canada

Re: links-home and filters in url

Post by jeannov » 2015-05-05 00:45

Pat,
you're welcome, it's a pleasure to share.

Jean

Post Reply