cupidare Posted August 12, 2018 Share Posted August 12, 2018 Hello, recently I have a problem with buttons (since updating to frozen and php 7.1). when I define a button without specifying the type the following strange thing appears in function tep_draw_button() // 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'; //here the value assignment is "s" instead of "submit" } And therefore the buttons don't work with a link. Has anyone a hint? Link to comment Share on other sites More sharing options...
♥Tsimi Posted August 12, 2018 Share Posted August 12, 2018 Not sure what you're trying to do but with Bootstrap you have 4 possibilities to create a button. See here for further info. If you want to have a button that has a link to go somewhere then you could use the first example. <a class="btn btn-default" href="#" role="button">Link</a> But it should be possible to do with tep_draw_button as well though. <?php echo tep_draw_button(BUTTON_TEXT, 'fas fa-chevron-right', tep_href_link('index.php')); ?> Link to comment Share on other sites More sharing options...
cupidare Posted August 12, 2018 Author Share Posted August 12, 2018 Hello @Tsimi, Thank you for your reply. Your way of button creation normally works for me. I want the following button tep_draw_button('call me', 'fa fa-lg fa-phone', "tel:0049XXXXXX", '', '', 'btn-info') The button itself appears, but it doesn't work (the link is missing). The re-definition of the button (None -> to "submit") just defines to "s" instead to "submit" EDIT: It works only when using Null instead of "" (empty). Is this something new? Link to comment Share on other sites More sharing options...
♥Tsimi Posted August 12, 2018 Share Posted August 12, 2018 If possible you should always use NULL instead of ' '. In this case you're right it only works with NULL. Link to comment Share on other sites More sharing options...
cupidare Posted August 12, 2018 Author Share Posted August 12, 2018 It is definetly a new behaviour. I used also some addons which also define the button with ' ' instead of Null... Is it a "problem" with php? Link to comment Share on other sites More sharing options...
♥Tsimi Posted August 12, 2018 Share Posted August 12, 2018 Not sure since when that is the case. I just tested it in an older EDGE shop and the same things happens there. Not sure if it is PHP related or not. But I guess as long it works with NULL it's OK. Link to comment Share on other sites More sharing options...
cupidare Posted August 12, 2018 Author Share Posted August 12, 2018 I changed (hopefully) all references with ' ' to null. But I was curious if anybody else has this kind of problem. Thank you! Link to comment Share on other sites More sharing options...
MrPhil Posted August 12, 2018 Share Posted August 12, 2018 isset() is not the same as empty(). See (for example) https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/. I would not be surprised if using '' never worked, but maybe it's a recent PHP change (tightening up things). Link to comment Share on other sites More sharing options...
Jack_mcs Posted August 12, 2018 Share Posted August 12, 2018 What is the purpose of the button? You have "'call me' as the text for the button but then you have the telephone number: "tel:0049XXXXXX". If this worked, what would want to display on the site? Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
♥Tsimi Posted August 12, 2018 Share Posted August 12, 2018 @Jack_mcs That's a so called click-to-call button. Most likely used when browsing with phones you can click on it and it will make the call to the number used inside the href.https://developers.google.com/web/fundamentals/native-hardware/click-to-call/ Link to comment Share on other sites More sharing options...
♥JcMagpie Posted August 12, 2018 Share Posted August 12, 2018 3 hours ago, cupidare said: tep_draw_button('call me', 'fa fa-lg fa-phone', "tel:0049XXXXXX", '', '', 'btn-info') You have several add-ons already available to provide this function on frozen and CE, This is just one of a number available. Navbar auto call now button Edge or you can use this by @raiwa Store Hotline BS Link to comment Share on other sites More sharing options...
Jack_mcs Posted August 12, 2018 Share Posted August 12, 2018 @TsimiThanks for the explanation. @cupidareThe following may work, though I haven't tested it. tep_draw_button('call me', 'fa fa-lg fa-phone', 'tel:0049XXXXXX"', 'primary', array('type'=>'button'), 'btn-info'); Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
cupidare Posted August 12, 2018 Author Share Posted August 12, 2018 I believe by now, that the problem is connected to this https://tehnoblog.org/php-7-1-warnings-illegal-string-offset-cannot-assign-empty-string-to-string-offset-working-fine-in-php-7-0-and-lower/ That means in php 7.1+ an array cannot be defined by an empty string without specifying it an array. Not sure whether this affects other parts of the code Link to comment Share on other sites More sharing options...
MrPhil Posted August 13, 2018 Share Posted August 13, 2018 That's one of those cases where the PHP maintainers are going around tightening up their code to better match the published specs. This often means that site code that worked before suddenly stopped working... technically it was invalid (sloppy coding) in the first place, but no one complained (until now). I wouldn't be surprised to see this problem popping up here and there in any PHP code, including osC. Link to comment Share on other sites More sharing options...
ce7 Posted November 26, 2018 Share Posted November 26, 2018 hi all, @cupidare @Tsimi @MrPhil @Jack_mcs @JcMagpie on my 234.1 BS (Edge) version, I install @Jack_mcs Jack's MATC modules, and have error message: Warning: Illegal string offset 'type' in /catalog/includes/functions/html_output.php on line 486 $params['type'] = 'submit'; Warning: Illegal string offset 'type' in /catalog/includes/functions/html_output.php on line 489 Warning: Illegal string offset 'type' if ( !in_array($params['type'], $types) ) { in /catalog/includes/functions/html_output.php on line 490 Warning: Illegal string offset 'type' $params['type'] = 'submit'; in /catalog/includes/functions/html_output.php on line 493 Warning: Illegal string offset 'type' if ( ($params['type'] == 'submit') && isset($link) ) { in /catalog/includes/functions/html_output.php on line 503 Warning: Illegal string offset 'type' if ( ($params['type'] == 'button') && isset($link) ) { in /catalog/includes/functions/html_output.php on line 511 Warning: Illegal string offset 'type' $button .= ' type="' . tep_output_string($params['type']) . '"'; in /catalog/includes/functions/html_output.php on line 530 if ( ($params['type'] == 'button') && isset($link) ) { any advice what I should to do make the errors go away? Many thanks! Lyn Link to comment Share on other sites More sharing options...
♥JcMagpie Posted November 26, 2018 Share Posted November 26, 2018 You shoud post in the support thread for the add-on or start your own thread, this question has nothing to do with original posting! Link to comment Share on other sites More sharing options...
♥JcMagpie Posted November 26, 2018 Share Posted November 26, 2018 The problem is with the php version you are using. The add-on is not compatiable with the version you are using. I'm sure this has already been coverd in this forum. You need to check that your key exists in the array or not, instead of simply trying to access it. The solution is to use the "isset" Replace: $myVar = $someArray['someKey'] With something like: if (isset($someArray['someKey'])) { $myVar = $someArray['someKey'] } Link to comment Share on other sites More sharing options...
MrPhil Posted November 26, 2018 Share Posted November 26, 2018 The problem is that $params was apparently not designated as an array, but is a scalar (such as a string). Older PHP versions would simply promote $params to an array (or do something similar) and do the array assignment. If $params is locally created, check that it uses array(). If it's passed in from elsewhere, you will need to figure out why it is a scalar and not an array. The error message says "illegal string offset", which leads me to believe that $params is a scalar string. Link to comment Share on other sites More sharing options...
ce7 Posted November 27, 2018 Share Posted November 27, 2018 hi all, thank you for reply. Sorry I google and this one comes up, and i stuck with tep_draw_button function codes, so thought it should be related, wrong judgement 😭 Yes I also found the other post from forums but it only mentioned php version, and I dont quite understand the solution. Thank you @JcMagpie Zahid for the example and thank you @MrPhil Phil for the explanation. Once again, thank you! Lyn Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 27, 2018 Share Posted November 27, 2018 @ce7Try this. In includes/functions/html_output.php, fine $types = array('submit', 'button', 'reset'); if ( !isset($params['type']) ) { $params['type'] = 'submit'; } and change it to if ( !isset($params['type']) ) { $params = array('type' => ''); $params['type'] = 'submit'; } Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
milerwan Posted September 5, 2019 Share Posted September 5, 2019 On 8/12/2018 at 5:00 PM, Jack_mcs said: @TsimiThanks for the explanation. @cupidareThe following may work, though I haven't tested it. tep_draw_button('call me', 'fa fa-lg fa-phone', 'tel:0049XXXXXX"', 'primary', array('type'=>'button'), 'btn-info'); @Jack_mcs I'm trying to get a "newwindow" with tep_draw_button function but I failed to make it : if ( isset($params['newwindow']) ) { $button .= ' target="_blank"'; } Do you know how to get it ? Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
Jack_mcs Posted September 5, 2019 Share Posted September 5, 2019 I think this will work echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'fa fa-angle-right', tep_href_link('index.php'), null, array('type'=>'button','newwindow'=>'1'), null ); Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
milerwan Posted September 5, 2019 Share Posted September 5, 2019 3 minutes ago, Jack_mcs said: I think this will work echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'fa fa-angle-right', tep_href_link('index.php'), null, array('type'=>'button','newwindow'=>'1'), null ); Thank you, it works ! NB: I've just found the same writing 'newwindows'=>'1' just 3 secondes before your reply but many thanks for your speed. ^^ Osc v2.3.4 BS "custom" PHP 7.3 compatible (710 modified files => o_O') Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.