PDA

View Full Version : Template depending of screen size ?


Eric
05-28-2006, 07:26 PM
Dear all,

I'm a recent french user of pixelpost, and this is my first post in this forum
I would like first to congratulate the authors of this photoblog. The code is well written and easy to understand.

I am now working on my own template and I would like to have an automatic selection of the template depending of the screen size of the user.
As it is possible to obtain the screen size with those javascript functions : window.innerWidth and window.innerHeight, I wonder if it is possible to switch from a template to an other after detecting screen size.

thank you in advance for your response;

Connie
05-28-2006, 07:52 PM
Eric,

welcome here! I am glad that you like it!

You can for sure include a template switch using javascript functions
because you can include javascript in the template

did you check out the simple template? It comes with a javascript function as well.. try to include the pixelpost-tags in the script, you have image-width and image-height as tags

Joe[y]
05-28-2006, 08:46 PM
it's certainly possible using some sort of javascript detection but there is no such addon or anything to switch the templates. looking at the styleswitcher we included in the simple template as connie suggested might be good start - perhaps you could modify it to include a certain stylesheet for certain screen resolutions.

Eric
05-29-2006, 04:32 PM
Thank you for your responses.
As I am not very good in javacript, it may take a long time before i understand the styleswitcher file code ... but i will try ...

eric

Eric
05-29-2006, 07:19 PM
OK,

It seems to run with an SQL update function in table config.
First, a javascript function is called when index.php is open, this function detect screen size, a conditional test is performed, and if the size exceed a fixed number, then a pop-up window is open. This pop-up contains the update function. Then the opener is reloaded and the pop-up closed.

I will send the code once it is "clean" ...

Eric
05-30-2006, 04:40 PM
The problem is that php is executed on the server side, and javascript client side.
So, if more than one people are connected at the same time, there will be a problem because each client will try to execute the same update request.

Another idea ?

(it seems that I am the only person interested by this subject ? :) )

Joe[y]
05-30-2006, 05:00 PM
(it seems that I am the only person interested by this subject ? :) )

haha. i think you might be ;) why exactly do you need different templates for different resolutions? perhaps there is a better solution.

RobbieMc
05-30-2006, 06:29 PM
You might be able to use your javascript function to simply record the screen size as a cookie, then use parts of my template switch hack to change the template depending upon the screen size. The following post sets out the switch hack, although I have no idea whether you can record the screen size as a cookie.

http://forum.pixelpost.org/showthread.php?t=3668

Good luck.
Rob

phild
05-31-2006, 01:20 PM
(it seems that I am the only person interested by this subject ? :) )

No, you're not, we're just silentely watching you struggling until you get it right