Page 1 of 1

Capturing selectedID in detail view

Posted: 2020-03-16 17:56
by bdurfee
For a detail view of a record, I want to display the selectedID of the record above the table heading. I'm using the header-extras.php file to add display it. When a user clicks on a record in table view, how to I capture the selectedID of the record so I can use it in header-extras.php?

Re: Capturing selectedID in detail view

Posted: 2020-03-16 18:24
by jsetzer
Hi,

do you really mean in "[...] detail view [...] above the table heading"?
I think there is no table in detail view.

Perhaps you can upload a screenshot and highlight the place you mean?

Best,
Jan

Re: Capturing selectedID in detail view

Posted: 2020-03-16 20:33
by bdurfee
I want to capture the record ID and use it in header-extras.php. The header-extras.php file in the hooks folder always puts the extra text above the page heading. The image below is the detail view of a particular record. "Additional text goes here." indicates where the output from header-extras.php would appear.

Image

Re: Capturing selectedID in detail view

Posted: 2020-03-16 20:54
by jsetzer
If you want to add the selected id about the header of the detail view, let me give it a first try. It's a bit tricky to avoid showing the id only in detail view and not in table view. Maybe someone else here will have a different and better approach?

Code in hooks/header-extras.php for inserting the selected record id above the header of a detail view:

Code: Select all

<?php 

// file: hooks/header-extras.php

if (isset($_REQUEST["SelectedID"]) && $_REQUEST["current_view"]==="TV") { ?>
    <h1 class="well text-center">Id: <?=$_REQUEST["SelectedID"]?></h1>
<?php } ?>
ezgif.com-resize (1).gif
ezgif.com-resize (1).gif (192.74 KiB) Viewed 5914 times

Is this what you were looking for?

Best,
Jan

Re: Capturing selectedID in detail view

Posted: 2020-03-17 02:13
by bdurfee
That was exactly it! Thanks!

Re: Capturing selectedID in detail view

Posted: 2020-03-21 13:31
by onoehring
Hi

I do not trust the "TV" as it seems (for me not to be set consistent).
In my Column-Value-Based-Permissions, I am using this approach to see if a detailview is requested (see my footer and read docs in the extension zip):

Code: Select all

$checkSelectedID = isset($_POST['SelectedID']) ? makeSafe($_POST['SelectedID']) : 0;    // check POST first!
$checkSelectedID = isset($_GET['SelectedID']) ? makeSafe($_GET['SelectedID']) : $checkSelectedID;  // if GET exist, overwrite POST!
If $checkSelectedID <> 0 then detailview requested.

Olaf