coppermine-gallery.com/forum

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: martinbl on January 29, 2004, 10:03:47 PM

Title: Is there a way to show a random theme with each visit?
Post by: martinbl on January 29, 2004, 10:03:47 PM
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?
Title: Is there a way to show a random theme with each visit?
Post by: Casper on January 29, 2004, 11:29:07 PM
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.
Title: Is there a way to show a random theme with each visit?
Post by: martinbl on January 30, 2004, 12:00:40 AM
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!
Title: Is there a way to show a random theme with each visit?
Post by: moorey on January 30, 2004, 03:37:29 AM
You can always add a mod to allow them to select a theme on the front page of CPG.
Title: Is there a way to show a random theme with each visit?
Post by: martinbl on January 30, 2004, 03:39:28 PM
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:
Title: Is there a way to show a random theme with each visit?
Post by: Joachim Müller on January 30, 2004, 03:47:44 PM
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
Title: Is there a way to show a random theme with each visit?
Post by: martinbl on January 30, 2004, 04:22:52 PM
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  :)
Title: Is there a way to show a random theme with each visit?
Post by: Nibbler on January 30, 2004, 07:03:14 PM
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....
Title: Is there a way to show a random theme with each visit?
Post by: martinbl on January 30, 2004, 11:59:20 PM
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?
Title: Is there a way to show a random theme with each visit?
Post by: martinbl on January 31, 2004, 02:28:09 AM
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?