change the background colour on first visit to the board

For support and discussion related to templates, themes, and imagesets in phpBB 3.2.
Post Reply
TheButcher2
Registered User
Posts: 657
Joined: Tue May 13, 2014 11:38 pm
Contact:

change the background colour on first visit to the board

Post by TheButcher2 » Wed May 08, 2019 9:20 pm

Hi guys would this be possible for the background colour of the board to be a different colour on the first visit each day when members log in, it is an idea I have been playing with for a while.

Peace


Dave

User avatar
Hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 902
Joined: Wed Dec 30, 2009 8:14 am
Name: Michael Miday
Contact:

Re: change the background colour on first visit to the board

Post by Hanakin » Thu May 09, 2019 1:56 am

you would need to do this in JavaScript with cookies or with an ext via a new db property if you wish it to be truly unique. or just make it completely random and with vanilla js

Code: Select all

<script>

function getRandomColor() {
  var letters = '0123456789ABCDEF';
  var color = '#';
  for (var i = 0; i < 6; i++) {
    color += letters[Math.floor(Math.random() * 16)];
  }
  return color;
}


document.body.style.backgroundColor = getRandomColor();
</script>
have not tested but if you adding this to your head should work

TheButcher2
Registered User
Posts: 657
Joined: Tue May 13, 2014 11:38 pm
Contact:

Re: change the background colour on first visit to the board

Post by TheButcher2 » Thu May 09, 2019 2:37 pm

Thanks for that, so I ad that code to the overall_header.tpl and place the background color codes on some other file?

User avatar
Hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 902
Joined: Wed Dec 30, 2009 8:14 am
Name: Michael Miday
Contact:

Re: change the background colour on first visit to the board

Post by Hanakin » Thu May 09, 2019 6:17 pm

no just add this to your overall header between the head tags and it should do what you want. the code is creating random color codes for you

TheButcher2
Registered User
Posts: 657
Joined: Tue May 13, 2014 11:38 pm
Contact:

Re: change the background colour on first visit to the board

Post by TheButcher2 » Thu May 09, 2019 6:33 pm

Ah thanks a lot, I'll try it,

Peace

Post Reply

Return to “[3.2.x] Styles Support & Discussion”