Losing search results

A place for users and developers of the Xataface to discuss and receive support.

Losing search results

Postby drm » Tue Aug 18, 2009 10:24 am

Hi there,

I'm using xataface to allow people to review data submissions in one table..with an associated table to add new records to review the submissions.

When the user clicks to add a new record in the associated table details page and saves said record, they're returned to the associated table details page but the Next button and search results are lost. The search results / Next button exist on the associated table details page until the save of the new record is made.

What can we do to retain the advanced search results for one table after a user has submitted a record to an associated table?


Let me know if I can explain this better!
drm
 
Posts: 4
Joined: Sun May 18, 2008 12:48 pm

Postby shannah » Wed Aug 19, 2009 7:27 am

HI drm,

To get a generic solution for this would be difficult as it is hard to guarantee that the record just inserted would be part of the found set of the previous advanced search, however you are able to redirect to any URL using the after_action_new() trigger.

e.g.
in your delegate class:

Code: Select all
function after_action_new(){
    header("Location: http://myurl.com/path/to/file?--msg=".urlencode('Record inserted successfully'));
    exit;
}


Xataface happens to store the previous query string inside the -query _POST parameter so you could access the previous result set as follows:

Code: Select all
function after_action_new(){
    $q = & Dataface_Application::getInstance()->getQuery();
    header('Location: '.DATAFACE_SITE_HREF.'?'.$q['-query'].'&--msg='.urlencode('Record inserted successfully'));
    exit;
}


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby drm » Wed Aug 19, 2009 9:21 am

Hi shannah,

I've tried the provided snippet in both the main submission table delegate class (To be specific, the files stored in ROOT/tables/TABLE_NAME/TABLE_NAME.php) and the related table..Neither spot seems to trigger any difference.

I'm not seeing the addition of the query elements that your modified header() redirection would suggest.

I'm using 0.7.1 if that makes any difference?


Thank you for your assistance and any further pointers you can provide.

shannah wrote:HI drm,

To get a generic solution for this would be difficult as it is hard to guarantee that the record just inserted would be part of the found set of the previous advanced search, however you are able to redirect to any URL using the after_action_new() trigger.

e.g.
in your delegate class:

Code: Select all
function after_action_new(){
    header("Location: http://myurl.com/path/to/file?--msg=".urlencode('Record inserted successfully'));
    exit;
}


Xataface happens to store the previous query string inside the -query _POST parameter so you could access the previous result set as follows:

Code: Select all
function after_action_new(){
    $q = & Dataface_Application::getInstance()->getQuery();
    header('Location: '.DATAFACE_SITE_HREF.'?'.$q['-query'].'&--msg='.urlencode('Record inserted successfully'));
    exit;
}


-Steve
drm
 
Posts: 4
Joined: Sun May 18, 2008 12:48 pm

Postby shannah » Wed Aug 19, 2009 10:20 am

Yes.. Don't believe that this trigger was included with 0.7.1. That would be why it's not working.

However, it shouldn't be hard to add this to your 0.7.1 install without having to upgrade the whole thing.

1. Download the latest Dataface/Utilities.php file (e.g. from http://weblite.ca/svn/dataface/core/tru ... lities.php
and place it in your Dataface directory (overwrite the existing Utilities.php if it is already there).

2. Add the following lines to your actions/new.php file:
Code: Select all
import('Dataface/Utilities.php');
            
Dataface_Utilities::fireEvent('after_action_new', array('record'=>$currentRecord));


Just after the line:

Code: Select all
if ($success){


If it doesn't have that line (i don't have 0.7.1 readily available for me to check), then find the part just before it calls "header('Location ....)", and insert it there.

If you run into an error using the $currentRecord variable (i'm not sure if is was set in 0.7.1), just change the snippet to:

Code: Select all
import('Dataface/Utilities.php');
Dataface_Utilities::fireEvent('after_action_new', array('record'=>null));
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby drm » Wed Aug 19, 2009 10:41 am

Hi shannah,

I followed your directions exactly, but still nothing.

Here's the resulting URL string that is brought up after adding a review to the system:

http://domain.com/admin/index.php?-acti ... lationship.

Perhaps this provides a better insight as to what's going on..perhaps a different trigger is required since it's a related_records action?

BTW - There was already a Utilities file (I updated it to the SVN copy) and there was already a similar line in actions/new.php. It was importing Utilities but the fireEvent was not specifying a currentRecord array..So I changed that line to match what you provided.

After making all your suggested changes..and adding the after_action_new back into the delegate class...Still no change in functionality after inserting a new record to reviews_table.


Your quick responses are first class..thanks for the awesome support on this issue!
drm
 
Posts: 4
Joined: Sun May 18, 2008 12:48 pm

Re: Losing search results

Postby drm » Wed Aug 11, 2010 4:45 pm

edited this post as it's irrelevant..figured it out.
drm
 
Posts: 4
Joined: Sun May 18, 2008 12:48 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 10 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved