Page 1 of 1

action switch

PostPosted: Fri Oct 17, 2008 7:28 am
by Martin Pruss
Hi steve
Almost 2 month without a question from me... :) maybe this is a indicator that my php and sql knowledge is getting continuously better.
But for the following problem I need your help.
In my application i have a custom action "order"
Everything works fine when i use this in list mode or edit mode, because this action is based on the cursor.
When I use this action in find mode the cursor position is not the same as in list mode because then the cursor depends on the list generated by the find button

Example URL Parameters:
List mode
Code: Select all
/dataface-0.7.1/partner/index.php?-sort=datum+desc&-table=neu_fragen&-action=browse&-cursor=1&-skip=0&-limit=30&-mode=list

find mode:
Code: Select all
/dataface-0.7.1/partner/index.php?-action=list&-sort=datum+desc&-table=neu_fragen&-cursor=0&-skip=0&-limit=30&-mode=list&-edit=1&kundenname=Stein

somewhere in my custom action I have an order button:
Code: Select all
echo "<b>Order online:</b><br><br><a href=\"$PHP_SELF?-action=order_action&-cursor=".$_GET['-cursor']."&a=1\">click here</a><br><br>";



I have two Ideas to prevent this:
the most simple way would be to remove the order button in "find mode"...

the action.ini for thiis button looks like this:
Code: Select all
[order_action]
label = nachbestellen
description = per e-mail
url = "{$this->url('-action=order_action')}"
accessKey = n
category = table_actions
icon = "{$dataface_url}/images/email-open-orange.gif"
mode = list
permission = view
order=5
condition = "$query['-table'] == 'neu_fragen'" 


like this it shows up in details, list and find.

What do i have to change to make it only show up in list and details but not in find mode?


Another option would be to get the real cursor number of the record instead of the Cursor number of the found set
But this seems more difficult to me. but maybe you have a good idea?
My main problem was that the URL Parameters always change in find mode depending on the form field and search term...
cheers and thanks in advance
Martin

PostPosted: Fri Oct 17, 2008 7:54 am
by shannah
What do i have to change to make it only show up in list and details but not in find mode?


Change the condition to:
Code: Select all
condition = "$query['-table'] == 'neu_fragen' and $query['-action'] != 'find'"

PostPosted: Fri Oct 17, 2008 8:18 am
by Martin Pruss
Thanks for your quick reply..
this works for the find mode... but not in the result list when I search for a record in find mode
I mean.. the result set is a list or a single record so it is possibly list mode,
does the list view generated by a find form differ from the normal list view
so that i can filter it out somehow?
cheers
martin

PostPosted: Fri Oct 17, 2008 8:44 am
by shannah
There is no difference between a normal list view and one generated by a find. What are you using the cursor parameter for? There should be another way to skin this cat that will be consistent across all actions.

-Steve

PostPosted: Sat Oct 18, 2008 7:43 am
by Martin Pruss
You are right..
but ...this easy change does it:
Code: Select all
condition = "$query['-table'] == 'neu_fragen' and $query['-action'] != 'list' and $query['-action'] != 'find'"


before that I tried
Code: Select all
condition = "$query['-table'] == 'neu_fragen' and $query['-action'] != 'browse' "
but I could'nt get it to work.

I redesign this action when i have more time...
(the medical term for this is "Procrastinaton")
:?
cheers
Martin