Is there a way to show a random theme with each visit? Is there a way to show a random theme with each visit?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Is there a way to show a random theme with each visit?

Started by martinbl, January 29, 2004, 10:03:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

martinbl

I have several themes to go with my coppermine 1.2, but because almost all my users a internet n00bs, I don't think they even know how to change themes.
And because I don't want all my work go to waste by everyone only seeing the default theme, I want to let the theme change every time a user visits my page.
Is there a way to do this?

Casper

Some of the themes are not really suitable for dialup connections, so any of your users on that may not like the idea.

Also, why not just change it in config regularly, so all your users are seeing the same at the same time.

Tip, if you plan to do additions, mods etc, just remember any changes involving the theme.php, template.html, theme.css, will have to be done in every theme you show.  This can be quite time consuming (and damn annoying), and is why I settled on one theme, modified it to what I wanted, and removed the theme choice form my site.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

martinbl

Quote from: "casper"Some of the themes are not really suitable for dialup connections, so any of your users on that may not like the idea.
.

The users with a dial up connection shouldn't visit photoalbums like mine :D
No serious, I'm from the Netherlands and only a few people are stuck with dial up connections, so that isn't the problem.
So if anyone knows how to do it, please tell me!

moorey

You can always add a mod to allow them to select a theme on the front page of CPG.

martinbl

Quote from: "moorey"You can always add a mod to allow them to select a theme on the front page of CPG.

Like I said before, the people who visit my page are from a small village where they visit the internet once a week.
They didn't even know how to register or upload a picture to coppermine, so I don't think they figure out how to change the themes themselves, not even with a guide.
So my questions still stands...  :cry:

Joachim Müller

as moorey said: of course this can be coded (and shouldn't be too hard), but since no-one who answered to your question can see sense in such a modification, you'll have to code this by yourself. Quick tip: look for the usage of the var "$theme"...

GauGau

martinbl

Quote from: "gaugau"as moorey said: of course this can be coded (and shouldn't be too hard), but since no-one who answered to your question can see sense in such a modification, you'll have to code this by yourself. Quick tip: look for the usage of the var "$theme"...
GauGau

Too bad, I don't have enough knowledge of php to alter it myself, I would just *beep* up the original code, that's why I asked it here  :?
Still, if anyone is bored, feel free to help me or explain what I should do  :)

Nibbler

OK, here we go...

The part of the code which decides what the theme should be, and loads the relevent theme file is in /include/init.inc.php.

So we need to add a bit of code to make this random.

So into init.inc.php at line 227, add the following code:


$rand_array[0] = 'theme1';
$rand_array[1] = 'theme2';
$rand_array[2] = 'theme3';

srand(time());

$rand_int = rand(0, 2);

$CONFIG['theme'] = $rand_array[$rand_int];


So instead of theme1,theme2,..... add the name of each theme to want to be available to be displayed. Also change the 2 in the $rand_int line to be the index number of the last theme you have - for example if your last theme is $rand_array[9] = 'eyeball'; you should also have $rand_int = rand(0, 9);

EDIT: This changes the theme for each page you view, gets a bit annoying....

martinbl

Quote from: "Nibbler"OK, here we go...

The part of the code which decides what the theme should be, and loads the relevent theme file is in /include/init.inc.php.

So we need to add a bit of code to make this random.

So into init.inc.php at line 227, add the following code:

I added the following code after:

Quoteif (mysql_num_rows($results)) {
        $USER_DATA = mysql_fetch_array($results);

Quote$rand_array[0] = 'alladin';
                $rand_array[1] = 'blauw3d';
                $rand_array[2] = 'bradpitt';
                $rand_array[3] = 'eenvoudiggrijs';
                $rand_array[4] = 'formeelblauwzwart';

                $rand_array[5] = 'lippenstiftrood';
                $rand_array[6] = 'mac';
                $rand_array[7] = 'muppets';
                $rand_array[8] = 'origineel';
                $rand_array[9] = 'sprookjes';
                $rand_array[10] = 'stripalbum';
                $rand_array[11] = 'vrolijkstrak';

                srand(time());

                $rand_int = rand(0, 11);

                $CONFIG['theme'] = $rand_array[$rand_int];

But it doesn't seem to work, not in user and not in admin mode.
Any idea what went wrong?

martinbl

Finnaly worked it out, but still one little problem left; only users who are logged in see a different theme everytime.
Is there a sollution so anonymous users see the theme change too?