Log in

View Full Version : How do I make my forum categories display threads and posts?


decipher442
04-06-2009, 12:26 AM
Hi,

I came accross this site and was wondering how I can make just my forum categories display all threads and posts in the category bar instead of the sub forum?

http://www.webtalkforums.com/

Is this done in the admin panel or is it a template modification or hack?

Thanks!

Lynne
04-06-2009, 02:30 AM
It isn't a default vbulletin thing. I don't know that I've seen a modification to do it either. But, the code to grab the posts and threads from the forum cache is on the bottom of the index.php page, so it's easy enough to copy and code it yourself.

decipher442
04-06-2009, 05:16 AM
What exactly is the code I would need (I can't find it), and would that code display all threads and posts of the categories sub forums?

merk_aus
04-06-2009, 07:12 AM
have you even looked or just have no idea and trying to get the code without having to do anything

decipher442
04-06-2009, 01:36 PM
I see this.. yes..
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);

But as said before.. if placed in the category bar would that code display all threads and posts of all the categories sub forums?

Do you know what template i would edit to have it placed into the category bar?

Lynne
04-06-2009, 02:01 PM
This is the full code used to get the total post and thread count. You need to modify it for your own purposes.
$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);

decipher442
04-06-2009, 02:15 PM
This is the full code used to get the total post and thread count. You need to modify it for your own purposes.
$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);


Thank you :)

Do you know what template I would edit to have it placed into the category bar? (I am assuming I can edit the template via the admin panel in style manager?)

Lynne
04-06-2009, 02:26 PM
To find the template to modify, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code. Sometimes the template is the one mentioned at the very top of the page source.

decipher442
04-07-2009, 04:37 AM
So far no luck :(

After lots of research I see that "forumhome_forumbit_level1_nopost" seems to be the template to edit so that i can make my category bar display total threads and posts of its sub-forums. (just to the left of the category collaps image)

but when I added the PHP code into the template (forumhome_forumbit_level1_nopost) it gave me an error and didn't work..


<if condition="!$show['collapsable_forums']">
<tbody>
</if>
<tr>
<td class="tcat" colspan="<if condition="$vboptions[showmoderatorcolumn]">6<else />5</if>">
<if condition="$childforumbits">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumbit_$forumid')"><img id="collapseimg_forumbit_$forumid" src="$stylevar[imgdir_button]/collapse_tcat{$collapseimg_forumid}.gif" alt="" border="0" /></a>

</if>
<a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
<a style="float:$stylevar[right]">
<?php

$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);
</a>

?>
<if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
<if condition="$show['subforums']"><div class="smallfont"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>
</tr>
<if condition="!$show['collapsable_forums']">
</tbody>
</if>
<if condition="$childforumbits">
<if condition="!$show['collapsable_forums']">
<tbody id="collapseobj_forumbit_$forumid" style="{$collapseobj_forumid}">
</if>
$childforumbits
<if condition="!$show['collapsable_forums']">
</tbody>
</if>
</if>


Does anyone know how I can do this?

NOTE: (Here is an example of what I would like my category bar(s) to look like...)
__________________________________________________ ______________________
[__Category_Title___________________________Threads : X,XXX, Posts: XX,XXX__[^]_]

** Threads: X,XXX, Posts: XX,XXX = Total amount of Threads and Post from all sub-forums of the category.
** [^] = category collapse image

Lynne
04-07-2009, 02:40 PM
You cannot put php in a template. You need to put the php into a plugin and then put the results from the plugin into your template.

decipher442
04-07-2009, 03:52 PM
You cannot put php in a template. You need to put the php into a plugin and then put the results from the plugin into your template.

What php hook location would I select to have this display in my category bar by the collapse image?

Thanks :)

Lynne
04-07-2009, 05:14 PM
Look in the forumdisplay.php page to see some hook locations and pick one that is evaled before those templates are evaled. I run my test site in debug mode which puts a list of all hook locations available on the page at the bottom. That helps a lot when trying to figure out which hook location to use.

decipher442
04-08-2009, 11:57 PM
I'm just not haveing any luck with this at all. :|

I know the template to edit i just do not know what hook to choose nor how to add the hook into that template where I want it displayed.

I am sure if I had the experience you had it would be more simple... but I don't.

Isn't there an easier an easier way of doing this?

maybe doing it something like seen here...
http://www.vbulletin.com/forum/showthread.php?t=113870

but obiousely displaying total threads and posts instead of a sponsor link.

Does anyone know how I can do this?

NOTE: (Here is an example of what I would like my category bar(s) to look like...)
__________________________________________________ ______________________
[__Category_Title___________________________Threads : X,XXX, Posts: XX,XXX__[^]_]

** Threads: X,XXX, Posts: XX,XXX = Total amount of Threads and Post from all sub-forums of the category.
** [^] = category collapse image



I see that this is the PHP code I need to add.. (That displays total threads and posts)

<?php

$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);
</a>

?>




And this is the template I need to edit... (forumhome_forumbit_level1_nopost)

<if condition="!$show['collapsable_forums']">
<tbody>
</if>
<tr>
<td class="tcat" colspan="<if condition="$vboptions[showmoderatorcolumn]">6<else />5</if>">
<if condition="$childforumbits">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumbit_$forumid')"><img id="collapseimg_forumbit_$forumid" src="$stylevar[imgdir_button]/collapse_tcat{$collapseimg_forumid}.gif" alt="" border="0" /></a>

</if>
<a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]">$forum[title]</a>
<a style="float:$stylevar[right]">
<if condition="$show['forumdescription']"><div class="smallfont">$forum[description]</div></if>
<if condition="$show['subforums']"><div class="smallfont"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>
</tr>
<if condition="!$show['collapsable_forums']">
</tbody>
</if>
<if condition="$childforumbits">
<if condition="!$show['collapsable_forums']">
<tbody id="collapseobj_forumbit_$forumid" style="{$collapseobj_forumid}">
</if>
$childforumbits
<if condition="!$show['collapsable_forums']">
</tbody>
</if>
</if>


From my understanding.... all I need to do now is create the plugin...
1. I DO NOT KNOW what hook to choose when creating the plugin, "Do you know?"
2. After the plugin is created what code snippet to I add into forumhome_forumbit_level1_nopost template to make the plugin work?


NOTE: (Here is an example of what I would like my category bar(s) to look like...)
__________________________________________________ ______________________
[__Category_Title___________________________Threads : X,XXX, Posts: XX,XXX__[^]_]

** Threads: X,XXX, Posts: XX,XXX = Total amount of Threads and Post from all sub-forums of the category.
** [^] = category collapse image

Thanks!

Lynne
04-09-2009, 02:55 AM
Actually, that is not the php code you need to add. I simply copied the code from index.php that shows how to get the posts and threads from the forumcache. You will need to modify that to get just the posts and threads from specific forum ids. As for plugin location, you can try forumhome_start. Like I said, look at the index page and find one that is eval before the template gets evaled.

Sorry I can't be more specific than that but I really don't know any specifics myself.

decipher442
04-10-2009, 01:49 AM
Thanks :)

One question though...

After I create the plugin what line of plugin call code do I add to that template?

Thanks

Lynne
04-10-2009, 02:14 AM
In the plugin, you will do some code and then assign the results to a variable, like $totalposts and $totalthreads. Then you would use those variables in the template.