onLoad only when NOT loaded from self?

chris.paschen

Chris Paschen
I have a custom PHP script that is running when the form is saved (onAfterProcess).
I also have a custom PHP script that needs to run onLoad.

However, I don't want to run the onLoad script IF the page is reloading itself (i.e. if the onAfterProcess has just run and returned to the same form).

Is there any way to make this happen?
I noticed there isn't any 'Condition' on PHP (like redirect plugins).

Is there a way within the PHP plugin's code area that I could get the reference of the previously displayed page (to determine if it was 'self')?
(Possibly someway related to how we use "{$_SERVER->REQUEST_URI}" on the redirect to redirect to the same page. Actually, that is what is causing the page reload - so maybe that redirect can 'feed' info to the onLoad script?)

Any ideas would be appreciated.
 
I found a functional (although not so glamorous, and potentially only temporary) solution - by using a session variable that I set in the onAfterProcess script and then check for its existence in the onLoad script.
I'm still open to any more graceful ways of handling this.
 
Well, that didn't appear to work either because I need to also track what page I'm on and which page I came from.
I'm still testing alternatives with the session variable approach; however, if someone has an idea how to handle this within the structure of Fabrik and the actions it would be appreciated.

BTW .. the main function of these scripts is displaying messages (i.e. $application->enqueueMessage). I just need to make sure that only the messages from one of these scripts is present at a time (one when the form is loaded (from a list page), one if the form is just saved and remains on the same page/form).
 
OK ... for anyone that needs to do something similar I found a solution.
By using a session variable
Code:
$session =& JFactory::getSession();
$session->set ('IncompleteNotice'.$bookID, 'true');
and checking the http referer (for a part of the edit form's URL)
Code:
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
I was able to make this work in a pretty reliable way.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top