Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2013, 03:38 AM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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>
Reply With Quote
  #2  
Old 08-16-2013, 03:23 PM
exel exel is offline
 
Join Date: Jan 2008
Location: Southern California
Posts: 161
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where are you trying to add that code?
Reply With Quote
  #3  
Old 08-16-2013, 11:50 PM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by exel View Post
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.
Reply With Quote
  #4  
Old 08-20-2013, 03:35 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
        



       }
Reply With Quote
2 благодарности(ей) от:
Lynne, PinkMilk
  #5  
Old 08-21-2013, 06:00 PM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 08-21-2013, 06:14 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What template are you putting $newmsg in?
Reply With Quote
  #7  
Old 08-21-2013, 06:52 PM
PinkMilk PinkMilk is offline
 
Join Date: May 2010
Location: Earth
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have tried, forumhome, forumhome_forumbit_level2_post and forumhome_forumbit_level1_nopost
Reply With Quote
  #8  
Old 08-21-2013, 07:40 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:53 PM.


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.03962 seconds
  • Memory Usage 2,236KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (2)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete