![]() |
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? |
The vB constant for the time is...
PHP Code:
|
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? |
Quote:
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 |
So what exactly do I make condition equal to if I want
6:00 AM or 8:00 PM etc |
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"; |
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']; |
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. |
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.
|
Post your code so we can see where you are.
|
OK, I was just testing it out on forumhome. I don't really know how hook locations work, but I knew forumhome_start would work for my template in forumhome (I thought so).
The following code, though, works. PHP Code:
My plugin with hook location forumhome_start: PHP Code:
Code:
<vb:if condition="$hourofday==19">stuff to do here</vb:if> What I'm really trying to do is change the background (CSS) depending on the time of day. There might be an easier way than the templates... I just don't exactly understand how plugins work because I'm still new to vB. |
Did you register $hourofday?
$templater->register('hourofday', $hourofday); |
Doesn't he have to make that global since he is not rendering any templates?
Jeremy8, Take a look at this hack and it will give you an idea of how to do what you are wanting to do. https://vborg.vbsupport.ru/showthread.php?t=244519 |
His question specifically is that when the uses "his" template, the var don't work. The first example was to prove his logic where he tagged it to an existing template hook var.
So where I see the problem is in rendering his template and registering his vars. |
Ok, I must have misunderstood. I thought he was just adding it to an already rendered template. I'll let you handle it then, sir. ;)
|
No problem I read that post twice last night, didn't reply, then read it again a few times before I answered again this morning. I even mocked up some code to make sure I made sense. But if we get him going, we'll have done good.
|
Well I think I have not been so clear about what I'm trying to do lol.
I was really just testing the time stuff out with that code I posted in my previous post. So let me say what I'm really trying to do, and then you could maybe put me in the right direction. Because I don't really know what approach to take. Plugins? Templates? CSS? Xml thingies... lol idk. Anyway, what I'm trying to do is have the background of one of my styles change according to the time (hour of day). Do I make a plugin at one of the CSS hook locations? I don't know... edit: I've moved on to this topic: https://vborg.vbsupport.ru/showthread.php?t=244834 Thanks for the info. |
All times are GMT. The time now is 01:41 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|