Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
BostonBob Posted May 25, 2017 Posted May 25, 2017 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
AlexWebsites Posted May 26, 2017 Posted May 26, 2017 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?
BostonBob Posted May 26, 2017 Author Posted May 26, 2017 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(); ?>
AlexWebsites Posted May 26, 2017 Posted May 26, 2017 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:
BostonBob Posted May 27, 2017 Author Posted May 27, 2017 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.
AlexWebsites Posted May 27, 2017 Posted May 27, 2017 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.
AlexWebsites Posted May 27, 2017 Posted May 27, 2017 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>
AlexWebsites Posted May 27, 2017 Posted May 27, 2017 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.
AlexWebsites Posted May 27, 2017 Posted May 27, 2017 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.
BostonBob Posted May 28, 2017 Author Posted May 28, 2017 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?
AlexWebsites Posted May 28, 2017 Posted May 28, 2017 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.
BostonBob Posted May 30, 2017 Author Posted May 30, 2017 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(); ?>
Maksim Posted May 31, 2017 Posted May 31, 2017 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!
PPlanet Posted September 13, 2017 Posted September 13, 2017 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?
BostonBob Posted September 14, 2017 Author Posted September 14, 2017 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"); ?>
PPlanet Posted September 15, 2017 Posted September 15, 2017 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.