Both of these tasks can be done with a bit of Javascript. ^w^~
html - This goes just after the list of links ends, but before the end of the navbar. Code:
<span class="navbar-right timeboth"></span> Code:
var now = new Date(); A css fix has been added to the class of "timeboth" with a bit of jQuery to align it with the links of the Bootstrap header, but this fix has not been applied to "time" and "timeimg" in case you want to use those elsewhere. Feel free to copy that fix to the other two, imitate the format, or make css amends in an actual stylesheet. (I wasn't sure whether you wanted to use these separately or not. For all I know, you may want to change your entire header to a sunrise/sun/sunset/moon based on the time of day!) Check out this jsbin I've made for a working example. Keep in mind that this code is a mix of both Javascript and jQuery (for convenience). The Bootstrap theme comes bundled with jQuery already, anyone who doesn't have it will have to include a link to prior to inserting a script that requires it. To anyone staring at this and going "wow that's neat" - yes, getMonth(); and getDate(); exist as well (and for full homework, see how the entire Date(); object in Javascript is constructed). On a final note, the data received is only as current as the page load. So it will display information based on the time the page was loaded, and pulls it's time directly from the user's computer, and not the server. It will be up to the script creators to make something accurate to server time that a user cannot change simply by messing their computer clock. It's good for visual effects, but I wouldn't rely on it to do much more than that. And unlike server side code, anyone can view the source of the page and view its Javascript - so if you're hiding promo codes in images, someone could easily find them all. It's also theoretically possible to pull data on the moon phase...... but I don't really feel like going into that. >_o |
If you want the php version to keep doing it like what you have in Creche: http://stackoverflow.com/questions/6...me-from-server
After getting the server time, do a smarty assign like $mysidia->template->assign("time",$variableYouCreated), this makes it possible to use the variable {$time} in the template.tpl (just like {$sidebar} or {$menu}!) inside the tags Kyttias has mentioned. Or like this http://www.smarty.net/docs/en/langua...tpl#idp6286592 |
It's definitely smarter to do it with PHP if for any reason it has to do with promo codes, for obvious security reasons! The best designed sites flawlessly integrate beauty with purpose. It's nice to know Smarty has a built in function for server time! Definitely would have saved me half the effort last night.
- On what file does the smarty assign need to be made? - To get an image to appear a specific time of day, but not display the time, I would still need at least this in Javascript: Code:
var now = new Date(); Code:
$t = date("H"); |
It works extremely perfect *_* Thank you so much, I even got it to display the server time by modifiying the script just a little.
This theme is awesome, btw, thanks for all the hard work :D |
- It can be used on any file through $mysidia->template->assign(), as long as you declare mysidia ($mysidia = Registry::get("mysidia")). I've been using most assigns in class_template though, in assignTemplateVars() function, or in class_frame, but that's personal choice I guess. I chose those two since they are always loaded for every page
- You can also do an assign for the image link and then in the template use it wherever you want, like: //in class_template PHP Code:
<img src={$timeimg}> You can assign both the time and the image at once like this if you wish. Of course, it will only refresh with a page refresh xD - PHP is pretty much normal with brackets, if the IF condition only has one line, you need no backets, like in Javascript ^^ |
Thankyou, that makes so much more sense. I hadn't had breakfast yet, my brain was in a fog. ^^
I added the code above into inside of the function assignTemplateVars(), which exists inside class_template.php, and it worked perfectly. My life suddenly got worlds easier. |
Utterly brilliant. WOW. Thank you so much, I just installed this and it's incredible!!
|
Utterly brilliant. WOW. Thank you so much, I just installed this and it's incredible!!
|
:O
As many many people before me have said.. THIS THEME IS AMAZING! I love Bootstrap and having it made into a theme for Mysidia Adoptables is just awesome!
|
This is amazing! :BIGO:
I found a bug though, on mobile devices submenus aren't present. |
All times are GMT -5. The time now is 08:55 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.