|
A 'shortcut query' button is simply a button that performs a pre-coded query. Pedserve includes various shortcut query buttons as standard on the animal search page - such as the 'All Animals', 'All Males' etc. buttons. Effectively they are buttons that hyperlink to search results screens with URL parameters hardcoded for a specific search. Hooks are provided so you can add your own shortcut query buttons to the various search screens. E.g. the
sub hookAnimalQueryShortcuts_Add {
my ($rmQueryPanelInfo, $strPanelPrefix, $strScriptSuffix,
$strOtherURLArgs, $rmArgsEx) = @_;
# Defer to an inbuilt function to add the standard pp query buttons:
&pdsHookStdImpl_AnimalQueryShortcuts_Add(
$rmQueryPanelInfo, $strPanelPrefix, $strScriptSuffix, $strOtherURLArgs, $rmArgsEx);
}
... which causes the inbuilt shortcut buttons to be added. But we can extend it to add a button that will list all animals that are parents - i.e. have one or more descendants, like this:
sub hookAnimalQueryShortcuts_Add {
my ($rmQueryPanelInfo, $strPanelPrefix, $strScriptSuffix,
$strOtherURLArgs, $rmArgsEx) = @_;
# Defer to an inbuilt function to add the standard pp query buttons:
&pdsHookStdImpl_AnimalQueryShortcuts_Add(
$rmQueryPanelInfo, $strPanelPrefix, $strScriptSuffix, $strOtherURLArgs, $rmArgsEx);
# Initialise a map of URL arguments that will define our
# shortcut query:
my %mURLArgs = ();
&pdsPrepackagedQueryInit(\%mURLArgs, $strPanelPrefix, 'a', 'All With Descendants');
# Add search term. This is the bit that limits the records to those where
# the given field (A_PRO_COUNTCHILDREN) is non-zero:
&pdsPrepackagedQueryAddTerm(\%mURLArgs, $strPanelPrefix, &pdsGetQueryDef('A'),
'A_PRO_COUNTCHILDREN', 'int-ge', 1);
# Now we create the target URL that is this query:
my $strScriptArgs = &pdsJoinURLArgs($strOtherURLArgs,
&pdsMakeURLArgsFromMap(\%mURLArgs));
my $strURL = &pdsMakeScriptURL($strScriptSuffix, $strScriptArgs);
# Finally we add this as a prepackaged query item to
# the query panel, with given title:
&pdsQueryPanelAddPrepackagedQuery($rmQueryPanelInfo,
'All With Descendants', $strURL);
}
... which results in a search screen that looks like this. The following table lists all the hook functions the system exposes for adding shortcut query buttons.
|
USEFUL LINKS: |
©1996-2009
Tenset Tech. Ltd
All Rights Reserved