Jump to content

Viewing Forum


Guest Please Delete

Recommended Posts

Maybe it's just me but I cannot believe that the new version of IPB still does not have the option to show amount of users in each forum for board view.

picture00014kp.png

vBulletin has had that forever and if I go to Invisionize all I get is a really bad mod that adds on querie per forum. I have it installed and it add around 25 queries bringing my total for board view up to 32.

I keep thinking Matt will bring this out with every release but no luck. It's a handy mod to have because it shows forum activity without having to open up each forum.

So how many other people would like to see this feature added?

Link to comment
Share on other sites

Seriously, I think you need to do some research. I had a 1.3 board installed that took 14 queries to run and had 28 forums and countless hacks installed.

I've seen big vBulletin sites with 50 forums that don't take 1 querie per forum. If a mod adds 3-4 queries that is considered high, for a mod to add 25 that is crazy.

So I don't think your statement is quite accurate because I have seen it done with only a few queries. My new question would be has anyone seen it done on a 2.0 and up board?

And my original question was why such a good feature is still missing with IPB?

Link to comment
Share on other sites

I would htink, for the main index page, all you'd have to do is edit the part that puts together the "Active Users" on the bottom of the page. It's going to pull the info from the session table anywya, without taking a look at it, I'd guess that it just pulls the time of last action, but if you edit it to pull the location fields as well, you could easily go through them all to see who is in each forum, and just do it that way.

Hell, you could even have the tooltip for each username be exactly where they are instead of the last action time

Link to comment
Share on other sites

Here is a mod that does it in one query. I have not been able to test it yet, but in theory it should work.

Active Members Per Forum
Originally written by Dean for IPB v2.0.X
Updated for IPB v2.1.X by LocationLohan

All credit goes to Dean ... I simply changed the
$ibforums to $this->ipsclass

Modification Description:
This modification adds a line of test below the forum description
on the main forums index page and sub forums page. It lists out
the current number of members/guests that are active/viewing that
particular forum

The line of text that is added looks like this: ({*} is replaced
with a number)

{*} User(s) Active In This Forum: {*} Members, {*} Guests


Files Affected During Installation:

* sources/action_public/boards.php
* cache/lang_cache/en/lang_boards.php
* Admin CP
o Edit 1 Existing Template

****************************************
* Open /sources/action_public/boards.php
****************************************

**************************************************
* Find (inside the show_subforums($fid) function):
**************************************************

			foreach( $this->ipsclass->forums->forum_cache[ $fid ] as $id => $forum_data )

			{

				//-----------------------------------------

				// Get all subforum stats

				// and calculate

				//-----------------------------------------

************ * Add Above: ************

			//-----------------------------------------

			// Active Members per Forum

			//-----------------------------------------


			foreach( $this->ipsclass->forums->forum_cache[ $fid ] as $id => $fd)

			{

				$forumids[] = $fd['id'];

			}


			$forum_ids = implode(",", $forumids);


			$cut_off = ($this->ipsclass->vars['au_cutoff'] != "") ? $this->ipsclass->vars['au_cutoff'] * 60 : 900;

			$time = time() - $cut_off;


			$this->ipsclass->DB->simple_construct(array('select' => 's.*, t.*', 'from' => "sessions s LEFT JOIN {$this->ipsclass->vars['sql_tbl_prefix']}topics t ON (s.in_topic=t.tid)", 'where' => '(s.in_forum IN ('.$forum_ids.') OR t.forum_id IN ('.$forum_ids.')) AND s.running_time>'.$time.' AND s.in_error!=1', 'order' => 's.running_time DESC'));

			$this->ipsclass->DB->simple_exec();


			$cached = array();

			$active = array('guests' => 0, 'members' => 0);

			$rows = array(0 => array('running_time' => time(), 'member_id' => $this->ipsclass->member['id']));


			while ($r = $this->ipsclass->DB->fetch_row())

			{

				$rows[] = $r;

			}

********************************** * Find (inside the same function): **********************************

					$temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ) );

*************** * Replace With: ***************

					//-----------------------------------------

					// Active Members per Forum

					//-----------------------------------------


					$active = array('guests' => 0, 'members' => 0);

					foreach ($rows as $i => $result)

					{

						if ($result['in_forum'] == $forum_data['id'] || $result['forum_id'] == $forum_data['id'])

						{

							if ($result['member_id'] == 0)

							{

								$active['guests']++;

							}

							else

							{

								if (empty($cached[$result['member_id']]))

								{

									$cached[$result['member_id']] = 1;

									$active['members']++;

								}

							}

						}

					}


					$active['total'] = ($active['members'] + $active['guests']);


					if ($active['total'] > 0)

					{

						$active_members = str_replace("<#TOTAL#>", $active['total'], $this->ipsclass->lang['active_members']);

						$active_members = str_replace("<#MEMBERS#>", $active['members'], $active_members);

						$active_members = str_replace("<#GUESTS#>", $active['guests'], $active_members);

					}

					else

					{

						$active_members = '';

					}


					//-----------------------------------------


					$temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ), $active_members );

************************************************ * Find (inside the process_all_cats() function): ************************************************

				foreach( $this->ipsclass->forums->forum_cache[ $root_id ] as $id => $forum_data )

				{

					//-----------------------------------------

					// Only showing certain root forums?

					//-----------------------------------------

************ * Add Above: ************

				//-----------------------------------------

				// Active Members per Forum

				//-----------------------------------------


				foreach( $this->ipsclass->forums->forum_cache[ $fid ] as $id => $fd)

				{

					$forumids[] = $fd['id'];

					if (is_array($this->ipsclass->forums->forum_cache[$fd['id']]))

					{

						foreach ($this->ipsclass->forums->forum_cache[$fd['id']] as $id => $f_d)

						{

							$forumids[] = $f_d['id'];

						}

					}					

				}


				$forum_ids = implode(",", $forumids);


				$cut_off = ($this->ipsclass->vars['au_cutoff'] != "") ? $this->ipsclass->vars['au_cutoff'] * 60 : 900;

				$time = time() - $cut_off;


				$this->ipsclass->DB->simple_construct(array('select' => 's.*, t.*', 'from' => "sessions s LEFT JOIN {$this->ipsclass->vars['sql_tbl_prefix']}topics t ON (s.in_topic=t.tid)", 'where' => '(s.in_forum IN ('.$forum_ids.') OR t.forum_id IN ('.$forum_ids.')) AND s.running_time>'.$time.' AND s.in_error!=1', 'order' => 's.running_time DESC'));

				$this->ipsclass->DB->simple_exec();


				$cached = array();

				$active = array('guests' => 0, 'members' => 0);

				$rows = array(0 => array('running_time' => time(), 'member_id' => $this->ipsclass->member['id']));


				while ($r = $this->ipsclass->DB->fetch_row())

				{

					$rows[] = $r;

				}

********************************** * Find (inside the same function): **********************************

								$temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ) );

*************** * Replace With: ***************

								//-----------------------------------------

								// Active Members per Forum

								//-----------------------------------------


								$active = array('guests' => 0, 'members' => 0);

								foreach ($rows as $i => $result)

								{

									if ($result['in_forum'] == $forum_data['id'] || $result['forum_id'] == $forum_data['id'])

									{

										if ($result['member_id'] == 0)

										{

											$active['guests']++;

										}

										else

										{

											if (empty($cached[$result['member_id']]))

											{

												$cached[$result['member_id']] = 1;

												$active['members']++;

											}

										}

									}

								}


								$active['total'] = ($active['members'] + $active['guests']);


								if ($active['total'] > 0)

								{

									$active_members = str_replace("<#TOTAL#>", $active['total'], $this->ipsclass->lang['active_members']);

									$active_members = str_replace("<#MEMBERS#>", $active['members'], $active_members);

									$active_members = str_replace("<#GUESTS#>", $active['guests'], $active_members);

								}

								else

								{

									$active_members = '';

								}


								//-----------------------------------------


								$temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ), $active_members );

************************************************ * Save, Upload /sources/action_public/boards.php ************************************************ ******************************************* * Open /cache/lang_cache/en/lang_boards.php ******************************************* ****************************** * Add (within the lang array): ******************************

'active_members' => "<#TOTAL#> User(s) Active In This Forum: <#MEMBERS#> Members, <#GUESTS#> Guests",

*************************************************** * Save, Upload /cache/lang_cache/en/lang_boards.php *************************************************** ******************************************************* * Edit Skin Template: (In ACP) Board Index --> ForumRow ******************************************************* ********************* * Add to Data Variables: *********************

,$active=""

******* * Find: *******

<i>{$data['moderator']}</i>

********************* * Add After (inline): *********************

<br /><i>{$active}</i>



*******************
* Save Template Bit
*******************

Link to comment
Share on other sites

Here is a mod that does it in one query. I have not been able to test it yet, but in theory it should work.



Had a few minutes to mess around tonight and decided to check this out - the code addition in the process_all_cats function results in an IPS Driver Error caused by the following line:

$forum_ids = implode(",", $forumids);

mySQL query error: SELECT s.*, t.* FROM ibf_sessions s LEFT JOIN ibf_topics t ON (s.in_topic=t.tid) WHERE (s.in_forum IN () OR t.forum_id IN ()) AND s.running_time>1129842478 AND s.in_error!=1 ORDER BY s.running_time DESC


SQL error: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near ') OR t.forum_id IN ()) AND s.running_time>1129842478 AND s.in_e

SQL error code: 

Date: Thursday 20th of October 2005 10:37:58 PM



Did the edits a few times, to make sure, and same result. If you want more testing done, let me know.

Link to comment
Share on other sites

My apologies ... for some reason I cannot edit my post. There were some table changes that I did not notice and there was a slight problem with one line of the code.

I was able to install it and get it working with the couple changes I made. Look for it to be at Invisionize in the coming days.

Keith

Link to comment
Share on other sites

Yeah I am using the mod for this and I have 33 queries run on the index page. I figured it out that the # viewing mod was what was causing so many eventually.

For anyone else making one, or even using the Cy one.... I would like it if you could make it where the admin can format it in a color they want, maybe change the size, bold it, etc. I am not sure if I can just find in the files wherever he has it showing the text to do and me format it that way or not. I guess I will have a look. But I forget what works in files. I cant remember if both html and bbcode work or only one or the other. I do know I have bolded mods many times, but cant remember what I used. I THINK I used html.

And btw, I too cant believe IPS keeps leaving this out themselves! I told them as such in a ticket recently. He thanked em for the suggestion, but didnt hint that it may be used soon.

Link to comment
Share on other sites

Yeah I am using the mod for this and I have 33 queries run on the index page. I figured it out that the # viewing mod was what was causing so many eventually.



For anyone else making one, or even using the Cy one.... I would like it if you could make it where the admin can format it in a color they want, maybe change the size, bold it, etc. I am not sure if I can just find in the files wherever he has it showing the text to do and me format it that way or not. I guess I will have a look. But I forget what works in files. I cant remember if both html and bbcode work or only one or the other. I do know I have bolded mods many times, but cant remember what I used. I THINK I used html.



And btw, I too cant believe IPS keeps leaving this out themselves! I told them as such in a ticket recently. He thanked em for the suggestion, but didnt hint that it may be used soon.



This is a skin issue - you can change this yourself, as long as the mod author has not hardcoded his HTML.
Link to comment
Share on other sites

Seriously, I think you need to do some research. I had a 1.3 board installed that took 14 queries to run and had 28 forums and countless hacks installed.



I've seen big vBulletin sites with 50 forums that don't take 1 querie per forum. If a mod adds 3-4 queries that is considered high, for a mod to add 25 that is crazy.



So I don't think your statement is quite accurate because I have seen it done with only a few queries. My new question would be has anyone seen it done on a 2.0 and up board?



And my original question was why such a good feature is still missing with IPB?



Then why does my VB 3.5 forum take so many queries? And what versions of VB were they running and were they modified in any way?! I have over 1,100 members, and before my site got fubar'd by the webhost, it had 3,500+ members and still laid on the queries thick. And don't even get me started on the plugins for VB and how many queries those usually take. Theres a difference betweem 1.3 and 2.1 Not even in the same league. Same for VB 3.0x and 3.5. Apples and Oranges.

So saying you had a 1.3 board really means nothing especially seeing as how IPB is up to 2.1 and numerous changes have been made since 1.3. Thats like comparing a 2005 Toyota with a 2006 Toyota of the same model.

I'd like to know what VB sites those were that didn't take 1 querie per forum.



BTW I have added an attachment pic of my IPB 2.1 forum using a mod I found at Invisionize.com. Look familiar?
Link to comment
Share on other sites

I think you had better go back and read the posts

I am well aware of this mod and have it installed.

You are missing the whole point of my post and some others since then.

The main question is why is this feature missing from IPB and can someone optimize this mod.

The answer has already been clearly posted, some members are working on a mod which will take roughly 2 queries.

As for comparing a 1.3 board, I was comparing one feature that I had installed which was the equivalent feature and used only 1-2 queries.

My suggestion was to try and copy that and see if we can apply something similar to 2.1x

And as a final note.... vBulletin has this feature and does it does NOT take one querie per forum. Personally I don't care that vBulletin is querie heavy in other places because I do not use them and do not intent to. My question is specific to one feature and if you read the whole topic again you will see that the solution is very very close.

Lastly, I posted this as a feature request for a future IPB release with a mod as a temporary workaround.

Thank you for listening

Link to comment
Share on other sites

i havent thought about this alot, but how would you do it without adding a query per forum?? Maybe a query to check the session table? Even so it would require atleast one extra query for something that (in essence) is a subjective need.



Aren't a lot of features subjective needs? That doesn't make them all the less worthy - you just pick and choose the ones you require.

I personally like the idea - good suggestion.
Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...