I need child record button to open in new window

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
jbaldree
Posts: 8
Joined: 2020-07-23 06:44

I need child record button to open in new window

Post by jbaldree » 2021-01-10 15:30

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;
}

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 2021-01-10 19:39

Hi,

can you be a bit more specific. I do not see a button in this code.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jbaldree
Posts: 8
Joined: 2020-07-23 06:44

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

Post by jbaldree » 2021-01-11 00:21

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>

jbaldree
Posts: 8
Joined: 2020-07-23 06:44

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

Post by jbaldree » 2021-01-11 00:37

<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>

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 2021-01-11 07:39

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jbaldree
Posts: 8
Joined: 2020-07-23 06:44

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

Post by jbaldree » 2021-02-02 02:20

These are the child tables for my "students" table. I want them to open in a new tab.
Attachments
Capture.JPG
Capture.JPG (27.68 KiB) Viewed 2405 times

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

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

Post by jsetzer » 2021-02-02 08:54

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 2385 times
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

jbaldree
Posts: 8
Joined: 2020-07-23 06:44

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

Post by jbaldree » 2021-02-02 16:36

I do not have that file in my hooks folder.
Attachments
notthere.JPG
notthere.JPG (18.71 KiB) Viewed 2362 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 2021-02-02 22:28

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
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply