Gossamer Forum
Home : Products : DBMan : Customization :

Call backs or edit on the fly.

Quote Reply
Call backs or edit on the fly.
I call this function a "call back" for lack of a better term. It allows you to edit a record in the middle of viewing search results. When you submit the record instead of displaying the changes to that one record, it will instead shoot you right back (ie callback) to the point you were at in your search results.

This will allow you to edit individual records as normal, but if you use the clickable link that is in a search results form, you will end up back at that same position in the search results.

In HTML.PL , in sub html_record

place this code:
$thisurl=qq|$db_script_url?$ENV{'QUERY_STRING'}|;
$thisurl=~ s/\?/~~/g; # Change ? delimiter to ~~ symbol.
$thisurl=~ s/\&/''/g; # Change & delimiter to '' symbol.
#
# Here is an example of a clickable link construct for a specific record.
$callback=qq|<A HREF="$db_script_url?uid=$db_uid&db=default&modify=$rec{$db_key}&modify_form_record=1&callback=$thisurl">(Edit)</A>| if ($per_mod);

Now you can insert the $callback variable into your HTML codings to provide the clickable link. But that's only 1/3 of it. Now we have to make sure we preserve the callback varaible contents while we edit the record.

In sub html_modify_form_record and in sub html_modify_failure just before &html_record_form (%rec);
add:

print qq|<input type=hidden name="callback" value="$in{'callback'}">| if ($in{'callback'});

And the final 1/3 of this puzzle.....
In sub html_modify_success add the following to the very first part of the sub ahead of everything else. We have to sent the browser the Location: before we print the html headers.

if ($in{'callback'}){
$in{'callback'}=~ s/~~/\?/g; # Change ? delimiter to ~~ symbol.
$in{'callback'}=~ s/''/\&/g; # Change & delimiter to '' symbol.
$in{'callback'}=$db_host_url . $in{'callback'};
print "Location: $in{'callback'}\n\n";
}


This mod should be ideal for use with JP Deni's relational mod since it can embed a clickable edit link in child records and will come right back to the parent record and make the parent refresh.

Wes
Subject Author Views Date
Thread Call backs or edit on the fly. ai4px 5154 Mar 21, 2011, 11:46 AM
Post Re: [ai4px] Call backs or edit on the fly.
delicia 4749 Mar 5, 2012, 4:13 AM