We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
[ ! ] Changing Banner Between Dates
Topic Started: Oct 1 2017, 01:19 PM (273 Views)
JamieMN
Member
[ *  *  * ]
http://www.modernnations.com/index/

Hi guys,

At the top left of the forum is our main banner, and we change this between dates for special occasions [I..e we have a christmas banner, specific birthday banners, halloween], but is there a way to do it so it'll automatically change to a specific banner between two dates, or on a specific date? without us having to manually amend each time?
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Admin CP > Board Template > Above the Board
Code:
 
<script type="text/javascript">
var holidayBanners = [
[startDate(2017, 10, 8), endDate(2017, 10, 11), 'http://b3.ifrm.com/30593/43/0/p3016949/_MN__Generic_Banner.png'],
[startDate(year, month, day), endDate(year, month, day), 'banner url'],
[startDate(year, month, day), endDate(year, month, day), 'banner url']
];
var currDate = new Date();
var i;
for (i = 0; i < holidayBanners.length; i++) {
if (currDate > holidayBanners[i][0] && currDate < holidayBanners[i][1]) {
$('#logo img').attr('src', holidayBanners[i][2]);
}
}

function startDate(year, month, day) {
return new Date(year, month - 1, day);
}

function endDate(year, month, day) {
return new Date(year, month - 1, day);
}
</script>
You can use the above, but you'll need to duplicate this line for each banner:
Code:
 
[startDate(2017, 10, 8), endDate(2017, 10, 11), 'http://b3.ifrm.com/30593/43/0/p3016949/_MN__Generic_Banner.png'],
Make sure to not include the comma at the end for the last row (as seen in the code above).

The dates are non-inclusive.
Offline Profile Goto Top
 
JamieMN
Member
[ *  *  * ]
Awesome, thank you DPM!
Will give it a shot and see how it goes, thank you again :-)
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Sure thing. Let me know how it goes.
Offline Profile Goto Top
 
Moonface
Member Avatar


This request has gone a lengthy period of time without any new activity, therefore it is being marked as expired. This means that the request was typically too time-consuming or irritating for coders (who provide this service voluntarily in their free time) to complete.

Thank you.
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Closed Requests · Next Topic »
Locked Topic