chuntse 3 Posted June 26, 2021 Hi, I want to use tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null, $style = null) to create a button which cn open a new window with parameters. I tried the params with 'newwindow', it eported error. Can it also created a button with onclick = "window.open('menubar=no, scrollbars=no, resizable=no, location=no, status=no')"; is it possible? Thanks in advanced. chuntse Share this post Link to post Share on other sites
Hotclutch 187 Posted June 26, 2021 Have you tried target="_blank" for parameters ? Share this post Link to post Share on other sites
chuntse 3 Posted June 26, 2021 I had just tried, it reported ' Warning: Illegal string offset 'type' ' if ( isset($params['newwindow']) ) { $button .= ' target="_blank" rel="noopener"'; } } else { $button .= '<button '; $button .= ' type="' . tep_output_string($params['type']) . '"'; } I had tried the params with 'newwindow'. it also reported the same error. oops.. chuntse Share this post Link to post Share on other sites
Hotclutch 187 Posted June 26, 2021 That error has to do with this line of code: $button .= ' type="' . tep_output_string($params['type']) . '"'; not the part with target="_blank" Share this post Link to post Share on other sites
Hotclutch 187 Posted June 26, 2021 I just checked the original tep_draw_button function and it does have this already: if ( isset($params['newwindow']) ) { $button .= ' target="_blank"'; } so if you do want to open a new window you should not have to do any additional coding. Share this post Link to post Share on other sites
chuntse 3 Posted June 26, 2021 Yes, I know this codes do not make error. I just said I tried tep_draw_button('New Window', null, null, null, null, 'newwindow', null) But it didn't work. Where should I put target="_blank"? chuntse Share this post Link to post Share on other sites
Hotclutch 187 Posted June 26, 2021 9 minutes ago, chuntse said: I just said I tried tep_draw_button('New Window', null, null, null, null, 'newwindow', null) When you tried this, what was the html output in view source code ? Share this post Link to post Share on other sites
chuntse 3 Posted June 26, 2021 I tried the parameter of newwindow in the function. I saw the error of ' Warning: Illegal string offset 'type' ' when I open the page and I saw the source code of html did not contain the target="_blank" between the label of button. Share this post Link to post Share on other sites
Hotclutch 187 Posted June 26, 2021 post your tep_draw_button code. Share this post Link to post Share on other sites
chuntse 3 Posted June 26, 2021 //// // Output a jQuery UI Button function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null, $style = null) { static $button_counter = 1; $types = array('submit', 'button', 'reset'); if ( !isset($params['type']) ) { $params['type'] = 'submit'; } if ( !in_array($params['type'], $types) ) { $params['type'] = 'submit'; } if ( ($params['type'] == 'submit') && isset($link) ) { $params['type'] = 'button'; } if (!isset($priority)) { $priority = 'secondary'; } $button = NULL; if ( ($params['type'] == 'button') && isset($link) ) { $button .= '<a id="btn' . $button_counter . '" href="' . $link . '"'; if ( isset($params['newwindow']) ) { $button .= ' target="_blank" rel="noopener"'; } } else { $button .= '<button '; $button .= ' type="' . tep_output_string($params['type']) . '"'; } if ( isset($params['params']) ) { $button .= ' ' . $params['params']; } $button .= ' class="btn '; $button .= (isset($style)) ? $style : 'btn-default'; $button .= '">'; if (isset($icon) && tep_not_null($icon)) { $button .= ' <span class="' . $icon . '" aria-hidden="true"></span> '; } $button .= $title; if ( ($params['type'] == 'button') && isset($link) ) { $button .= '</a>'; } else { $button .= '</button>'; } $button_counter++; return $button; } This is the codes of the tep_draw_button. Share this post Link to post Share on other sites
chuntse 3 Posted June 26, 2021 Thanks a lot for your replies. I read this function again. It seems the button with $link and $params need to be set, then it will generate the target="_blank". tep_draw_button('New Window', null, 'test.php', null, array('type'=>'button','newwindow'=>''), null) I will try this later to see if it works Share this post Link to post Share on other sites
YePix 34 Posted June 27, 2021 here the button with all parameters <span class="btn btn-success"><a href='<?php echo tep_href_link('product_info.php', 'products_id=' . $printlist['products_id']); ?>', target="_blank" onclick="window.open(this.href,this.target,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=800,height=640,screenX=150,screenY=150,top=5,left=650'); return false;" class="btn btn-info btn-xs" role="button"><?php echo '<i class="fa fa-shopping-cart"></i>' . BUTTON_BUY_NOW;?></a></span> Share this post Link to post Share on other sites
chuntse 3 Posted June 27, 2021 @YePix Thanks a lot for your information. Does it really can prompt up a new window or a new tab? chuntse Share this post Link to post Share on other sites
YePix 34 Posted June 27, 2021 (edited) vor einer Stunde schrieb chuntse: @YePix Thanks a lot for your information. Does it really can prompt up a new window or a new tab? chuntse Naturally. All you have to do is adjust the appropriate link 'product_info.php', 'products_id=' . $printlist['products_id'] Edited June 27, 2021 by YePix Share this post Link to post Share on other sites