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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2006, 12:21 PM
johnstires johnstires is offline
 
Join Date: Mar 2006
Posts: 195
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default New Posts Code not working in header

In vba cmps I moved this block of code to my header template. It was from the welcome block and was redundant.

The $newposts does not work on my vba pages or my regular forum pages. It just says "New posts: " without a number. Why would this be? I think it needs to call a php file but I'm not sure how to do that. Can someone please help enlighten me?

Code:
<a href="$vboptions[bburl]/search.php?$session[sessionurl]do=getnew">$vbphrase[new_posts]</a>: $newposts
Reply With Quote
  #2  
Old 10-18-2006, 01:59 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You will have to also use the relevant php code, it's best to utilize the plugin system for this. Give this a shot..

In Admin CP go to Plugins & Products > Add New Plugin.

Leave the top box at vbulletin

In Hook Location choose global_start from the dropdown

For the title put something like New Posts

Put this in the Plugin PHP Code box:
PHP Code:
$getnewposts $db->query_first("
                    SELECT COUNT(*) AS count
                    FROM " 
TABLE_PREFIX "post AS post
                    " 
iif($vbulletin->options['threadmarking'], 'LEFT JOIN ' TABLE_PREFIX 'threadread AS threadread ON (threadread.threadid = post.threadid AND threadread.userid = ' $vbulletin->userinfo['userid'] . ')') . "
                    WHERE dateline >= " 
$vbulletin->userinfo['lastvisit'] . iif($vbulletin->options['threadmarking'], ' AND dateline > IF(threadread.readtime IS NULL, ' . (TIMENOW - ($vbulletin->options['markinglimit'] * 86400)) . ', threadread.readtime)')
            );

            
$db->query_write("UPDATE " TABLE_PREFIX "session SET newposts = '$getnewposts[count]' WHERE userid = '" $vbulletin->userinfo['userid'] . "'");

            
$newposts vb_number_format($getnewposts['count']); 
That should do it, I am not positive that it will carry to every page but I believe it should with global_start.
Reply With Quote
  #3  
Old 10-18-2006, 02:43 PM
johnstires johnstires is offline
 
Join Date: Mar 2006
Posts: 195
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This seems like it may be kinda advanced for me. I'm intrigued. Is there some background reading on understanding this?
Reply With Quote
  #4  
Old 10-18-2006, 02:47 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, it's pretty straight forward. You nailed it with your first post when you assumed it was calling php code from a file, so you are on the right path. As for a background on it, you can google php how to or sql tutorials and find many results that are helpful.

As for this modification, if you follow the instructions it should do what you ask. If there is a part you need help with in here, let me know the details and I will point you in the right direction.
Reply With Quote
  #5  
Old 10-18-2006, 04:52 PM
johnstires johnstires is offline
 
Join Date: Mar 2006
Posts: 195
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your instruction worked perfectly, thanks!

I guess I want to understand why I am doing what I am doing as opposed to just copying and pasting (which is fine by me!).

It took me a couple of months to get the hang of templating and I'm just getting into how much it allows me to customize. I can actually understand what I'm doing.

Things like adding a plugin is totally new territory for me. Where did you get that code from? I assume you pulled it from another location.

Is there VB documentation on this? I know that I can read up on PHP and MYSQL, but I think learning it in the context of VB would be a good step for me.

Thanks again!
Reply With Quote
  #6  
Old 10-18-2006, 05:17 PM
ericgtr's Avatar
ericgtr ericgtr is offline
 
Join Date: Apr 2003
Location: Portland, Oregon
Posts: 1,407
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, that is correct I pulled that code straight out of the /modules/welcomeblock.php file. The thing to remember is that each template calls variables from an associated php file, sometimes trying to figure out which file can be a pain however. This is where turning on Debug Mode can be handy because it will allow you to see each template associated with it's related php file.

The (newly implemented) plugin system was designed so we can just add specific code to designated areas according to where they fit. As to where before you had to manually edit the .php file and then re-upload it. It also gives you an option to turn it off and on which is another great tool when it comes to testing.

Mostly it's a matter of digging and experimenting at first, ensuring that you backup every single existence of every change so you can put things right back to the way they are in the event it doesn't work. You can also have a look through some of the tutorials in the Article forums for some how to's that will help you gain a better understanding of vB and how it works.
Reply With Quote
  #7  
Old 10-18-2006, 08:26 PM
johnstires johnstires is offline
 
Join Date: Mar 2006
Posts: 195
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool, thanks for the tips. I look forward to digging some more.
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 05:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08071 seconds
  • Memory Usage 2,233KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete