vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   if category x contains new posts (https://vborg.vbsupport.ru/showthread.php?t=301243)

PinkMilk 08-16-2013 03:38 AM

if category x contains new posts
 
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>

exel 08-16-2013 03:23 PM

Where are you trying to add that code?

PinkMilk 08-16-2013 11:50 PM

Quote:

Originally Posted by exel (Post 2439194)
Where are you trying to add that code?

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.

BirdOPrey5 08-20-2013 03:35 PM

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
       



  }

Replace 999 with the forumid of the forum (or category) you want to check

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
       



      }


PinkMilk 08-21-2013 06:00 PM

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:

if ($isnew == "new") {
 
     
$newmsg "Yes";  

  } else {

    
$newmsg "No";


and added $newmsg to templates, so not sure where I'm going wrong.

BirdOPrey5 08-21-2013 06:14 PM

What template are you putting $newmsg in?

PinkMilk 08-21-2013 06:52 PM

Have tried, forumhome, forumhome_forumbit_level2_post and forumhome_forumbit_level1_nopost

BirdOPrey5 08-21-2013 07:40 PM

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.


All times are GMT. The time now is 06:51 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01116 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete