The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
How do you write an if condition to show something if if category x contains new posts?
Dummy code explaination: Code:
<if condition="category 3 has new posts">Show this text</if> |
|
#2
|
|||
|
|||
|
Where are you trying to add that code?
|
|
#3
|
|||
|
|||
|
On forumhome, I don't use forumhome_forumbit_level1_nopost so I'm probably just going to have to write a plugin to query db, tbh I have kind of given up on the idea but if you have a solution it would be much appreciated.
|
|
#4
|
||||
|
||||
|
In a plugin on global_start add this code
Code:
include('includes/functions_forumlist.php');
global $vbulletin, $lastpostarray;
// call fetch_last_post_array() first to get last post info for forums
cache_ordered_forums(1);
if (!is_array($lastpostarray))
{
fetch_last_post_array(-1);
}
$forumidx = 999; //Set your forum id to check here
$lastpostinfo = (empty($lastpostarray[$forumidx]) ? array() : $vbulletin->forumcache["$lastpostarray[$forumidx]"]);
$forumx = $vbulletin->forumcache["$forumidx"];
$isnew = fetch_forum_lightbulb($forumidx, $lastpostinfo, $forumx);
if ($isnew == "new")
{
//Execute code here if the forumid chosen above contains new posts
}
This works for me, I repeat this code multiple times in the plugin to check multiple forumids- Code:
$forumidx = 998; //Set your forum id to check here
$lastpostinfo = (empty($lastpostarray[$forumidx]) ? array() : $vbulletin->forumcache["$lastpostarray[$forumidx]"]);
$forumx = $vbulletin->forumcache["$forumidx"];
$isnew = fetch_forum_lightbulb($forumidx, $lastpostinfo, $forumx);
if ($isnew == "new")
{
//Execute code here if the forumid chosen above contains new posts
}
|
|
#5
|
|||
|
|||
|
Thank you BOP but dosen't seem to work for me, I did everything as instructed and the execution code is just a simple if else
PHP Code:
|
|
#6
|
||||
|
||||
|
What template are you putting $newmsg in?
|
|
#7
|
|||
|
|||
|
Have tried, forumhome, forumhome_forumbit_level2_post and forumhome_forumbit_level1_nopost
|
|
#8
|
||||
|
||||
|
This exact code works for me...
Code:
include('includes/functions_forumlist.php');
global $vbulletin, $lastpostarray;
// call fetch_last_post_array() first to get last post info for forums
cache_ordered_forums(1);
if (!is_array($lastpostarray))
{
fetch_last_post_array(-1);
}
$forumidx = 1; //Set your forum id to check here
$lastpostinfo = (empty($lastpostarray[$forumidx]) ? array() : $vbulletin->forumcache["$lastpostarray[$forumidx]"]);
$forumx = $vbulletin->forumcache["$forumidx"];
$isnew = fetch_forum_lightbulb($forumidx, $lastpostinfo, $forumx);
if ($isnew == "new")
{
//Execute code here if the forumid chosen above contains new posts
$newmsg = "Yes";
} else {
$newmsg = "No";
}
In your vBulletin Options -> General Settings -> Thread/Forum Read Marking Type, is it set to Database (automatic forum marking)? It may need to be for this to work. |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|