*

FezMonki

  • **
  • 8 posts
Manual positioning of contact button.
« on: August 14, 2021, 05:46:03 AM »
Hi, I've tried placing the contact button manually in my theme with "<?php if(function_exists('im_contact_button')) { im_contact_button(); } ?>"

The button seems to work, but I get a warning (I do have PHP errors turned on):
Warning
: Trying to access array offset on value of type null in
/var/www/html/oc-content/plugins/instant_messenger/index.php
on line
364

Any way around that? Thanks.
« Last Edit: August 14, 2021, 02:03:18 PM by FezMonki »

*

FezMonki

  • **
  • 8 posts
Re: Manual positioning of contact button.
« Reply #1 on: August 15, 2021, 05:23:46 PM »
Alright, I fixed it by adding osc_item() and added the check to hide the button from the item poster like in the normal form:

Quote
<?php if (osc_logged_user_id()!=osc_item_user_id()){
          if(function_exists('im_contact_button')) { im_contact_button(osc_item()); }
} ?>

I'd suggest updating it in the plugin configuration tab in admin under "PLUGIN SETUP" for the next release, cheers.

*

MB Themes

Re: Manual positioning of contact button.
« Reply #2 on: August 16, 2021, 09:27:13 AM »
@FezMonki
It is bit strange as if item object is not provided, item ID should be found using osc_item_id() function, that is why it is not mentioned in guide.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

FezMonki

  • **
  • 8 posts
Re: Manual positioning of contact button.
« Reply #3 on: August 16, 2021, 02:06:51 PM »
I'm very new to programming so apologies if I say something stupid, but googling the error I found a lot of threads about this being a new warning in php8 (comparing to an index that does not exist yet). So here when we compare to null, it throws a warning:


I wondered why the hook button didn't have warning, and found it has the item declared:


So I just added it to mine.

*

MB Themes

Re: Manual positioning of contact button.
« Reply #4 on: August 17, 2021, 10:37:25 AM »
you can change it to !isset($item['pk_i_id']) || $item['pk_i_id'] == ''
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots