Thursday, August 14, 2008

Redirecting to a page

Say after an action in Xataface (eg. finished adding a new record), by default it goes to the edit action for that record you just added. But say you want it to go to the new action to add another another. There are a few ways to do this:


  1. One way to do this is to grab the current query:


    The --msg query string variable allows you to display a confirmation message. We put an exit after the header function to make sure nothing else in the script runs.

  2. The above way works, but it leaves the primary id of the record you just added in the url. Probably not the best thing to do, another way to do it is just use the header function and manually enter the query parameters:

    header('Location: '.DATAFACE_SITE_HREF.'?-table=tablename&-action=new


    I used the DATAFACE_SITE_HREF constant variable here which provides the path your application. You NEVER want to hardcode your application path since portable. You can put this function like in your after_action_new() trigger so that after you add a record, it allow you to add another record right away.

No comments: