Page 1 of 1

I need child record button to open in new window

Posted: 2021-01-10 15:30
by jbaldree
How do I edit the code to make the button open in a new window on a child record?

// child table: starmath
$res = sql("SELECT `st_id` FROM `students` WHERE `st_id`='{$selected_id}'", $eo);
$st_id = db_fetch_row($res);
$rires = sql("SELECT COUNT(1) FROM `starmath` WHERE `student`='" . makeSafe($st_id[0]) . "'", $eo);
$rirow = db_fetch_row($rires);
if($rirow[0] && !$AllowDeleteOfParents && !$skipChecks) {
$RetMsg = $Translation["couldn't delete"];
$RetMsg = str_replace('<RelatedRecords>', $rirow[0], $RetMsg);
$RetMsg = str_replace('<TableName>', 'starmath', $RetMsg);
return $RetMsg;
} elseif($rirow[0] && $AllowDeleteOfParents && !$skipChecks) {
$RetMsg = $Translation['confirm delete'];
$RetMsg = str_replace('<RelatedRecords>', $rirow[0], $RetMsg);
$RetMsg = str_replace('<TableName>', 'starmath', $RetMsg);
$RetMsg = str_replace('<Delete>', '<input type="button" class="button" value="' . $Translation['yes'] . '" onClick="window.location = \'students_view.php?SelectedID=' . urlencode($selected_id) . '&delete_x=1&confirmed=1\';">', $RetMsg);
$RetMsg = str_replace('<Cancel>', '<input type="button" class="button" value="' . $Translation[ 'no'] . '" onClick="window.location = \'students_view.php?SelectedID=' . urlencode($selected_id) . '\';">', $RetMsg);
return $RetMsg;
}

Re: I need child record button to open in new window

Posted: 2021-01-10 19:39
by pbottcher
Hi,

can you be a bit more specific. I do not see a button in this code.

Re: I need child record button to open in new window

Posted: 2021-01-11 00:21
by jbaldree
Is this the button?

<a class="visible-xs btn btn-default btn-lg btn-block hidden vspacer-sm" href="Contacts_view.php?filterer_student=<%%URLVALUE(st_id)%%>&<%%EMBEDDED%%>" id="xs_Contacts_link"><i class="glyphicon glyphicon-list-alt"></i> Contacts</a>

Re: I need child record button to open in new window

Posted: 2021-01-11 00:37
by jbaldree
<a class="hidden-xs btn btn-default btn-lg pull-right hidden hspacer-sm" href="starmath_view.php?filterer_student=<%%URLVALUE(st_id)%%>&<%%EMBEDDED%%>" id="starmath_link"><i class="glyphicon glyphicon-list-alt"></i> STAR Math</a>
<a class="visible-xs btn btn-default btn-lg btn-block hidden vspacer-sm" href="starmath_view.php?filterer_student=<%%URLVALUE(st_id)%%>&<%%EMBEDDED%%>" id="xs_starmath_link"><i class="glyphicon glyphicon-list-alt"></i> STAR Math</a>
<input type="hidden" id="starmath_hclink" value="starmath_view.php?filterer_student=<%%URLVALUE(st_id)%%>&<%%EMBEDDED%%>">
<div class="clearfix"></div>
</div>

Re: I need child record button to open in new window

Posted: 2021-01-11 07:39
by pbottcher
Hi,

that is a least a link that will be displayed like a button.

Can you make a screenshot to show where you want to click to open the record in a new window.

Re: I need child record button to open in new window

Posted: 2021-02-02 02:20
by jbaldree
These are the child tables for my "students" table. I want them to open in a new tab.

Re: I need child record button to open in new window

Posted: 2021-02-02 08:54
by jsetzer
For standard child-link buttons (at the top of your detail view) you can use following javascript:

Code: Select all

// file: hooks/TABLENAME-dv.js
$j(".children-links > a").attr("target", "_blank");
Z9g3yBhhgS.gif
Z9g3yBhhgS.gif (116.25 KiB) Viewed 2414 times

Re: I need child record button to open in new window

Posted: 2021-02-02 16:36
by jbaldree
I do not have that file in my hooks folder.

Re: I need child record button to open in new window

Posted: 2021-02-02 22:28
by pbottcher
Just create that file and put the code in.

Just a warning, as the child table load later, you need to make sure that your code will execute once the child table is available.

See also
viewtopic.php?f=7&t=4147&p=16241&hilit= ... ble#p16241