GX Admin's Blog / How to avoid redirection to AJAX modules after editing a content in eZpublish ?

How to avoid redirection to AJAX modules after editing a content in eZpublish ?

Each time a common module is called (like "content" or other simple modules, like AJAX ones), and so every time a content page, or an AJAX module in an extension is called our dear kernel (/index.php) updates a session variable called: LastAccessesURI.

This variable is used when leaving edit mode, to return to the previous page, or when a log is finished, to return to the URL that was requested before having to log ...

This is annoying because chronologically, when a person displays a page in the front office containing an AJAX call to an eZpublish extension, these steps are followed:

  • URL of the desired page requested by the user -> URI set in LastAccessesURI
  • URL of an AJAX module called by the browser -> AJAX URI set in LastAccessesURI

So, because the last request to eZpublish is an AJAX one, to an AJAX module, the wrong URI will be used when the user exits from edit mode, or is redirected after a successful /user/login, (or another module using LastAccessesURI variable), and then, the user is redirected to the AJAX module in full view, which is not the last page the user saw.

Fortunately, eZpublish is great (when you read directly the kernel code): we can declare our module in a particular way to prevent the LastAccessesURI variable to be updated. In the kernel, in index.php, a condition protects an update to the LastAccessesURI variable:

if ( ... && !in_array( $module->uiContextName(),
     array('edit','administration','browse','authentication')
     )) {
    $http->setSessionVariable("LastAccessesURI",
          $currentURI);
 }

So now, you can redeclare your AJAX module like an admin module, and that's all!

In your extension/.../modules/.../module.php, use the following code:

$ViewList['get'] = array(
     'script' => 'get.php',
     'ui_context' => 'administration'
 );

Comments

Many thaks

In Ez everything seems possible. The problem is to know how and were to find it.
So many thanks that spared me a couple of hours when not a couple of days.

This is my personnal blog about eZpublish, Android, and others...

Follow me with this feed !
 
 
 
Mon Tue Wed Thu Fri Sat Sun
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31