Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted May 25, 20177 yr Hello, Like many of you, I had a difficult time when the chat room finally shut down. But with some modifications, I've gotten ArrowChat to be a suitable replacement. I've created a script that will grab the number of active users from the chat room. However, I'm puzzled as to how to implement this into the NavBar as Invision Chat used to be. How can I do a PHP Include -- in the Nav Bar? Or is it even possible? Thanks, BB
May 26, 20177 yr I am interested in this as well as its the one feature that users miss, to see how many people are in chat. Your script that you are using, how are you grabbing the info from arrowchat, API?
May 26, 20177 yr Author This is the script I put together and do a simple php include on the forums front page. <?php $servername = "localhost"; $username = "usernsame"; $password = "password"; $dbname = "database"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $chatters_online = 0; $sql = "SELECT * FROM `arrowchat_chatroom_users` WHERE `session_time` > ( UNIX_TIMESTAMP() - 360 )"; $result = $conn->query($sql); $row_cnt = mysqli_num_rows($result); $chatters_online = $row_cnt; echo $chatters_online; $result->free(); $conn->close(); ?>
May 26, 20177 yr Ah so arrowchat you install server side. I'm using Chatwee and need to utilize their api for user data then php include it. Just found this Notification counts ipsNotificationCount is a class for a floating bubble which can denote a notification count of some kind. The parent element should have a non-static position for this class to work correctly. By default, the notification bubble will be offset to the top and right, but this could be overwritten with additional specific styles if desired. Usage: <!-- The element the notification belongs to --> <!-- position: relative; is set inline here, but avoid that in practice --> <a href='#' class='ipsButton ipsButton_primary ipsButton_medium' style='position:relative'> A button with notification <span class='<strong>ipsNotificationCount</strong>'>12</span> </a> This would render:
May 27, 20177 yr Author The problem is that the menu is generated within the framework. I want to put a php include within a ipsnotification span to show the number of users online in the chat room, just as IPS used to do. I don't see how they did it previously so I can't figure out how to replicate it. I used ChatWee -- I couldn't stand the fact that the bubbles we so big -- if you have 10 people in a room you can't follow. So I deleted it -- I had high hopes -- but in the end -- I was able to really customize Arrowchat to do all that I wanted.
May 27, 20177 yr 17 hours ago, BostonBob said: The problem is that the menu is generated within the framework. I want to put a php include within a ipsnotification span to show the number of users online in the chat room, just as IPS used to do. I don't see how they did it previously so I can't figure out how to replicate it. I used ChatWee -- I couldn't stand the fact that the bubbles we so big -- if you have 10 people in a room you can't follow. So I deleted it -- I had high hopes -- but in the end -- I was able to really customize Arrowchat to do all that I wanted. yep, I see that. I'm not sure if you can manually add it to the navigation template. I put my chat # code into a pages block so I can call it within the IPS templates {block="chatwee_count"} but not sure how to add it to the primary menu item.
May 27, 20177 yr A temporary solution might be to add it to the menu would be something like this to the global > navbaritems template at the bottom after all the code if you have the pages app using some template logic and blocks, or use php include and urls. <li class='ipsNavBar_primary'> <a href='{pageurl="chatroom"}'>CHAT <span class='ipsNotificationCount'>{block="chatroom_count"}</span> </a> </li>
May 27, 20177 yr Here's a quick update on this as I'm messing around. If you create a menu item in the ips menu manager and use for the title Title <span class='ipsNotificationCount'>1</span> You'll get the notification bubble with 1 in it, however I can't seem to embed a block or template logic between the <span> in that count spot. Not sure about a php include or other.
May 27, 20177 yr Got it working. The IPS menu title does seem to accept html so I used for the menu title: Chat<span class='ipsNotificationCount users-count'></span> the <span class='users-count'></span> is called from a js file that grabs the data from the chatwee api. I ended up putting the js into a block and adding that block to the global template before the head and voila...seems to work and display chat count.
May 28, 20177 yr Author Hmmm... I can't seem to grab the count and post it. So I thought about what you said, and that seemed like a decent work around -- converting the PHP script to making it look like a .JS file. So right now I changed the code to this <?php // Set the output as Javascript header("content-type: application/x-javascript"); // Include connection info $servername = "localhost"; $username = "dbusername"; $password = "dbpassword"; $dbname = "dbdatbase"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $chatters_online = 0; $sql = "SELECT * FROM `arrowchat_chatroom_users` WHERE `session_time` > ( UNIX_TIMESTAMP() - 360 )"; $result = $conn->query($sql); $row_cnt = mysqli_num_rows($result); $chatters_online = $row_cnt; echo "document.write('<span class='ipsNotificationCount users-count'>$chatters_online</span>');"; $result->free(); $conn->close(); ?> Then I added a line to the .htaccess file to read the .php file Redirect /arrowchat/chat_count.js http://www.whatisyoursite.com/arrowchat/chat_count.php Then I added to the Menu Manager -- <i class="fa fa-comments"></i> Chat<script language="JavaScript" src="https://www.whatisyoursite.com/arrowchat/chat_count.js"></script> Now I see that the JS is being included in the source code -- but the document is not parsing the JS. Is there a way that you parsed the JS in the menu differently? I see it in the source code so it's including it -- but not parsing it. I tried putting in the menu the code for insert into a site {{include '/arrowchat/chat_count.js';)} it didn't parse it -- as it just printed that. Now I have the JS to print the code when calling it directly -- with a document print -- but I still can't include it. Any ideas?
May 28, 20177 yr js and php doesn't work in the menu manager title directly. I've got it where the element with class="users-count" is calling the function from my js file, so then I just added the span and combined the classes. I'm not sure if you can call php variables in the menu. I'm calling from an API like so: $(document).ready(function() { // use element with class="users-count" and call the function chatwee_getCount(); // set interval to refresh window.setInterval("chatwee_getCount();", (10*1000)); }); function chatwee_getCount() { chatwee_getData(function(data){ if(data.publicList.length===0) $('.users-count').hide(); else $('.users-count').html(data.publicList.length); }); } Seems to work when I add in menu manager title: Chat<span class='ipsNotificationCount users-count'></span> The ipsNotificationCount is part of the IPS framework, users-count is the added # of chatters.
May 30, 20177 yr Author I've still not figured it out as far as the number to post in the nav bar. However I was able to post -- who's online and the total number of chatters on the front page using the php/text widget and this code to grab users / number of users for ArrowChat. <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "dbase"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $chatters_online = 0; $sql = "SELECT `name` from `core_members` WHERE `member_id` IN (SELECT `user_id` FROM `arrowchat_chatroom_users` WHERE `session_time` > ( UNIX_TIMESTAMP() - 360 ));"; $i = 1; $result = $conn->query($sql); $row_cnt = mysqli_num_rows($result); $chatters_online = $row_cnt; while ($row = $result->fetch_array()) { echo $row['0']; if ($i < $row_cnt) { echo ', '; } $i ++; } echo "<br /><br /><strong>Total number of chatters online: "; echo $chatters_online; $result->free(); $conn->close(); ?>
May 31, 20177 yr 22 hours ago, BostonBob said: I've still not figured it out as far as the number to post in the nav bar. However I was able to post -- who's online and the total number of chatters on the front page using the php/text widget and this code to grab users / number of users for ArrowChat. <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "dbase"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $chatters_online = 0; $sql = "SELECT `name` from `core_members` WHERE `member_id` IN (SELECT `user_id` FROM `arrowchat_chatroom_users` WHERE `session_time` > ( UNIX_TIMESTAMP() - 360 ));"; $i = 1; $result = $conn->query($sql); $row_cnt = mysqli_num_rows($result); $chatters_online = $row_cnt; while ($row = $result->fetch_array()) { echo $row['0']; if ($i < $row_cnt) { echo ', '; } $i ++; } echo "<br /><br /><strong>Total number of chatters online: "; echo $chatters_online; $result->free(); $conn->close(); ?> Screenshot of how it shows up? thanks!
September 13, 20177 yr On 6/1/2017 at 6:35 PM, BostonBob said: I've been trying to implement this without success. How do you call the include? I assume you put the include file in the top level of IPB and you are calling it from the BoardIndexTemplate. I'm still on 3.4 by the way; wouldn't be the same code?
September 14, 20177 yr Author On 9/13/2017 at 4:13 AM, PPlanet said: I've been trying to implement this without success. How do you call the include? I assume you put the include file in the top level of IPB and you are calling it from the BoardIndexTemplate. I'm still on 3.4 by the way; wouldn't be the same code? Go to the front page of the site -- left arrow -- Manage Blocks Insert -- PHP & TXT Widget Then a <?php include_once("/path/to/phpscript/users-online-show-name.php"); ?>
September 15, 20177 yr Thanks; that's for 4.x while I'm still on 3.4. It may be handy for the future nonetheless. I sorted mine by hiring a freelancer. Thanks again.
Archived
This topic is now archived and is closed to further replies.