Announcement

Collapse
No announcement yet.

How To Show Thread And Post Counts For Forums Even When User Doesn't Have Access

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How To Show Thread And Post Counts For Forums Even When User Doesn't Have Access

    Many forum admins want guests (or other users who don't have access to a private forum) to see that there are threads and posts in that forum. Under the current system, if a user doesn't have access to a forum then it will show 0 threads and 0 posts in the forum listing. You can use this method to show the true counts regardless of forum permissions.

    Note, If you have a ton of forums then this code can add a lot of processing time to your forumhome and forumdisplay pages.

    Go to your:

    Admin CP -> Styles & Templates -> Style Manager -> « » -> PHP Include Code Templates -> phpinclude_start

    Add this code:

    Code:
    // IF FORUMHOME OR FORUMDISPLAY PAGE
    if (THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'forumdisplay')
    {
    	// GET FORUM COUNTERS
    	$forumcounts= $DB_site->query("SELECT forumid, replycount, threadcount
    		FROM " . TABLE_PREFIX . "forum
    		");
    
    	// SET VALUES
    	while ($forumcount = $DB_site->fetch_array($forumcounts))
    	{
    		$forumreply[$forumcount[forumid]] = $forumcount[replycount];
    		$forumthread[$forumcount[forumid]] = $forumcount[threadcount];
    	}
    }
    Then go to your:

    Admin CP -> Styles & Templates -> Style Manager -> « » -> Forum Home Templates -> forumhome_forumbit_level1_post

    Replace the red code...

    Code:
    		<td class="alt2" nowrap="nowrap">$forum[lastpostinfo]</td>
    		<td class="alt1">[color=red]$forum[threadcount][/color]</td>
    		<td class="alt2">[color=red]$forum[replycount][/color]</td>
    		<if condition="$vboptions['showmoderatorcolumn']">
    		<td class="alt1"><div class="smallfont">$forum[moderators]&nbsp;</div></td>
    		</if>
    ...with the blue code:

    Code:
    		<td class="alt2" nowrap="nowrap">$forum[lastpostinfo]</td>
    		<td class="alt1">[color=blue]{$GLOBALS[forumthread][$forum[forumid]]}[/color]</td>
    		<td class="alt2">[color=blue]{$GLOBALS[forumreply][$forum[forumid]]}[/color]</td>
    		<if condition="$vboptions['showmoderatorcolumn']">
    		<td class="alt1"><div class="smallfont">$forum[moderators]&nbsp;</div></td>
    		</if>
    Make a similar change to the forumhome_forumbit_level2_post template.
    Last edited by Jake Bunce; Tue 24 Aug '04, 1:39pm.

  • #2
    In addition, to complete the effect, you can add a conditional to replace "Never" in the Last Post field with "Private":

    Admin CP -> Styles & Templates -> Style Manager -> « » -> Forum Home Templates -> forumhome_forumbit_level2_post

    Add the red code:

    Code:
    <tr align="center">
    	<td class="alt2"><img src="$stylevar[imgdir_statusicon]/forum_$forum[statusicon].gif" alt="" border="0" /></td>
    	<td class="alt1Active" align="$stylevar[left]" id="f$forum[forumid]">
    		<div>
    			<a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]"><strong>$forum[title]</strong></a>
    			<if condition="$show['browsers']"><span class="smallfont">(<phrase 1="$forum[browsers]">$vbphrase[x_viewing]</phrase>)</span></if>
    		</div>
    		<if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
    		<if condition="$show['forumsubscription']"><div class="smallfont"><strong><a href="subscription.php?$session[sessionurl]do=removesubscription&amp;f=$forum[forumid]">$vbphrase[unsubscribe_from_this_forum]</a></strong></div></if>
    		<if condition="$show['subforums']"><div class="smallfont" style="margin-top:$stylevar[cellpadding]px"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
    	</td>
    	<td class="alt2" nowrap="nowrap">[color=red]<if condition="$forum[lastpostinfo] == 'Never'">Private<else />[/color]$forum[lastpostinfo][color=red]</if>[/color]</td>
    	<td class="alt1">$forum[threadcount]</td>
    	<td class="alt2">$forum[replycount]</td>
    	<if condition="$vboptions['showmoderatorcolumn']">
    	<td class="alt1"><div class="smallfont">$forum[moderators]&nbsp;</div></td>
    	</if>
    </tr>
    $childforumbits
    Make a similar change to the forumhome_forumbit_level1_post template.

    Comment


    • #3
      One shortcoming of this modification is that it doesn't include posts / threads from child forums in the counts. For example, if your forums are like this:

      Category 1
      - Forum1
      - - forum1a
      - - forum1b
      - Forum2


      Then the post and thread counts for Forum1 will only include posts in Forum1, and not those in forum1a and forum1b.

      So if you have a forum tree with postable forums nested within postable forums, then the reported post and thread counts with this modification will be wrong.

      If this is your situation, then a file hack would be more appropriate than this template mod. For help with a hack you should post on www.vbulletin.org.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X