MyBB Community Forums

Full Version: is there?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
In reply of my last thread: https://community.mybb.com/thread-200186-page-2.html

Since i can't bump my thread, i have made a new one to continue it...

So, i added the html to my forum header include and my home page (but nothing seems to change)

Code: 
<script type="text/javascript">
$(document).ready(function(){
    var dt = new Date(),
    var currentHour = dt.getHours();
    $("#logo img").attr("http://crystalforums.cf", "/logo/logo_" + currentHour + ".png");
    $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; ');
});



and nothing seems to update or the background and logo is the same as it was before...


Plus there is an image behind the logo that labeled as "bk.png" and i want to add the 24 hr change to it as well.

I'm using the latest version of the theme "Project"
The "attr" method accepts the attribute name and value as parameters. The "css" method accepts the rule name and rule value as attributes. I fixed the calls you, give this a try:

<script type="text/javascript">
$(document).ready(function(){
   var dt = new Date(),
   var currentHour = dt.getHours();
   $("#logo img").attr('src', 'http://crystalforums.cf/logo/logo_' + currentHour + '.png');
   $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed');
   $('body').css('background-size', 'cover');
});
(2016-09-09, 11:32 PM)SentoWeb Wrote: [ -> ]The "attr" method accepts the attribute name and value as parameters. The "css" method accepts the rule name and rule value as attributes. I fixed the calls you, give this a try:

<script type="text/javascript">
$(document).ready(function(){
   var dt = new Date(),
   var currentHour = dt.getHours();
   $("#logo img").attr('src', 'http://crystalforums.cf/logo/logo_' + currentHour + '.png');
   $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed');
   $('body').css('background-size', 'cover');
});

Nope, still the same background and logo...

jQuery(document).ready(function($){
   var dt = new Date();
   var currentHour = dt.getHours();
   $("#logo img").attr('src', 'http://crystalforums.cf/logo/logo_' + currentHour + '.png');
   $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed');
   $('body').css('background-size', 'cover');
});

Fixed it for you, you needed to swap the "," with a ";" between the two variable declarations. With multiple declarations you don't have to repeat "var" for every variables, I still prefer simple declarations.
(2016-09-10, 08:50 AM)SentoWeb Wrote: [ -> ]

jQuery(document).ready(function($){
   var dt = new Date();
   var currentHour = dt.getHours();
   $("#logo img").attr('src', 'http://crystalforums.cf/logo/logo_' + currentHour + '.png');
   $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed');
   $('body').css('background-size', 'cover');
});

Fixed it for you, you needed to swap the "," with a ";" between the two variable declarations. With multiple declarations you don't have to repeat "var" for every variables, I still prefer simple declarations.

THANK YOU, JUST ONE FINAL THING. How would i update the bk.png? I got the logo and background but there is that image behind the logo called bk.jpg and i want to update that every 24hrs as well. I'm using the latest version of the Project theme.'.
(2016-09-10, 09:06 AM)shattered Wrote: [ -> ]
(2016-09-10, 08:50 AM)SentoWeb Wrote: [ -> ]

jQuery(document).ready(function($){
   var dt = new Date();
   var currentHour = dt.getHours();
   $("#logo img").attr('src', 'http://crystalforums.cf/logo/logo_' + currentHour + '.png');
   $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed');
   $('body').css('background-size', 'cover');
});

Fixed it for you, you needed to swap the "," with a ";" between the two variable declarations. With multiple declarations you don't have to repeat "var" for every variables, I still prefer simple declarations.

THANK YOU, JUST ONE FINAL THING. How would i update the bk.png? I got the logo and background but there is that image behind the logo called bk.jpg and i want to update that every 24hrs as well. I'm using the latest version of the Project theme.'.

I assume you want to update that before it is shown to the user. You could create a simple PHP file to redirect all your requests to your desired logo URL:

/logo.php

$logo = "images/bk_".date("j").".jpg";
header('Location: http://yourforum.com/'.$logo);

Then you can set the logo url to yourforum.com/logo.php. Not the most elegant solution but you can perform even more advanced checks and decide which logo to show. 

An alternative is to create a MyBB plugin which sets the value of $myLogo using the same logic, then you can swap $theme['logo'] with that variable, saving you a HTTP request.
OK, THANK YOU, I'LL TEST IT SOON.

I TESTED THE NEW CODE YOU GOT ME AND THE LOGO ONLY UPDATED, NOT THE BACKGROUND.

http://prntscr.com/cgdiz5
Should have waited on a reply on the other thread instead of making another one.

Other thread. https://community.mybb.com/thread-200186.html
I realized if you visit the /bk folder, you can see the images and click and open it but when you the direct link, it goes to an error page...
jQuery(document).ready(function($){
   var dt = new Date();
   var currentHour = dt.getHours();
   $("#logo img").attr('src', 'http://crystalforums.cf/logo/logo_' + currentHour + '.png');
   $('body').css('background', '#FFF url(http://crystalforums.cf/bk/bg_'+currentHour+'.png) no-repeat center center fixed');
   $('body').css('background-size', 'cover');
});

Make sure all the backgrounds are using bg_ at the beginning of them and using png or whatever it using for the images at the end of them. I've had problems with that in the past and can't reach my sites right now to help out on the coding like SentoWeb did.
Pages: 1 2 3