I'm probably not fully awake this morning because it seems so trivial but I cannot figure it out.
I need a hook to track when user access a certain page (path = 'export-csv
'). This page is not a node neither a View and neither a form... It is just a "path". And I need a hook that I could use in my custom module's file, not in templates.
I thought of something like hook_preprocess_page
or but it doesn't seem to work.
I need a hook called before the page is fully loaded because the page is never truly displayed (it is a page for downloading a file and it just shows the download popup).
If you need precisions about my code or something, just ask. But I don't think that it is necessary.
Thanks in advance of course.
edit: I found a part of solution here but I still have trouble because of the nature of the page. I never truly land on the page and I think the hook is not called before the popup happens.
The callback function of this page looks like this:
function grap_contact_export_csv_page() {
header("Cache-Control: public");
header("Content-Type: application/octet-stream");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0");
header("Content-Disposition: attachment; filename=\"grape-export.csv\";" );
header("Content-Transfer-Encoding: binary");
$fp = fopen('export.csv', 'r') or die('Impossible d\'accéder au fichier');
echo fread($fp, filesize('export.csv'));
fclose($fp);
drupal_exit();
}