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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2010, 06:35 PM
Jeremy8 Jeremy8 is offline
 
Join Date: Jan 2010
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What is the time variable?

Here's an example of what I'm trying to do.

<vb:if condition="$time==1">stuff to do here</vb:if>

So it will do something at a certain time.

I just made "$time==1" up... I'm trying to figure out what goes there. Can anyone help?
Reply With Quote
  #2  
Old 06-16-2010, 07:13 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The vB constant for the time is...

PHP Code:
<vb:if condition="TIMENOW==1">stuff to do here</vb:if> 
Reply With Quote
  #3  
Old 06-16-2010, 07:22 PM
Jeremy8 Jeremy8 is offline
 
Join Date: Jan 2010
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What do I put where the 1 is? I'm not sure what TIMENOW looks like.

For example, what if I want 6:00 AM?
Reply With Quote
  #4  
Old 06-16-2010, 07:28 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jeremy8 View Post
What do I put where the 1 is? I'm not sure what TIMENOW looks like.

For example, what if I want 6:00 AM?
TIMENOW is a 10 digit number derived from php time(). You use vbtime and vbdate to see what it is in text form. Or you can use plain old php date().

It's in seconds. So to get an hour ago, minus 3600. To go an hour in the future, add 3600.

Maybe this will help Free Tool: Convert Unix Time Stamps To Readable Time and Date
Reply With Quote
  #5  
Old 06-16-2010, 07:52 PM
Jeremy8 Jeremy8 is offline
 
Join Date: Jan 2010
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So what exactly do I make condition equal to if I want

6:00 AM

or 8:00 PM

etc
Reply With Quote
  #6  
Old 06-16-2010, 08:13 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, first you have to work out the users timezone if they are a member. So look at $vbulletin->options['hourdiff']

something like

$timestamp = TIMENOW - $vbulletin->options['hourdiff'];

Then you can get the hour with $hourofday = date("G", $timestamp )

Then you can work out the condition.

if ($hourofday == 6) $message = "6AM";
if ($hourofday == 20) $message = "8PM";
Reply With Quote
  #7  
Old 06-16-2010, 09:56 PM
Jeremy8 Jeremy8 is offline
 
Join Date: Jan 2010
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, well I'm doing this in my templates. I put that stuff in a plugin... but I don't really understand how plugins work.

Because then I went to my template and put <vb:if condition="$hourofday==6">stuff to do here</vb:if> and messed with the times

I also did <vb:if condition="$hourofday">test</vb:if> to see if it even existed... but $hourofday didn't have any value apparently... ?

this was my plugin:

Code:
$timestamp = TIMENOW - $vbulletin->options['hourdiff'];
$hourofday = date("G", $timestamp );
Reply With Quote
  #8  
Old 06-16-2010, 09:58 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:

$hourofday = intval(date("G", $timestamp ));

I've seen that resolve a similar situation.

Of course, it has to be 6 am to work too.
Reply With Quote
  #9  
Old 06-16-2010, 10:48 PM
Jeremy8 Jeremy8 is offline
 
Join Date: Jan 2010
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, I'm seeing now that it works as a plugin alone. But what I don't understand is how I take that variable from the plugin and use it as the condition for my if-statement in the template.
Reply With Quote
  #10  
Old 06-17-2010, 12:15 AM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Post your code so we can see where you are.
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 08:50 AM.


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.07473 seconds
  • Memory Usage 2,253KB
  • Queries Executed 11 (?)
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)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete