user theme selector

I would like to allow gallery visitors to select themselves a theme from those installed by the admin and selectable in the back end.

My question is, before I embark on testing this and waste a lot of time, is there any zenphoto inherent reason why a front end user/gallery visitor selected theme (full theme selector, not just style switcher) would not work?

A simple CSS style switcher is not sufficient, since more and more themes also include js code to implement lightboxes, image transitions, etc.

I was thinking that this could perhaps be implemented by using a theme.php include at the top of each zenphoto file and allow it to switch the stylesheets along with the scripts included in different theme headers. Next I proceeded to search for code that might already do this and I stumbled upon this example http://vsbabu.org/webdev/phpdev/themer.html. which with very little modification (it seems to me) might do the job.

A better solution might be to use the themeoptions.php file to do the above, except I don't see how this could include the right header code for the selected theme.

I will post the solution, if I manage to figure it out.

Comments

  • There is no `good` reason why you cannot do this. But there are some considerations. Zenphoto can have only one theme at a time. But the Internet is a vast and wild place. There is no reason to believe that people viewing your site will do so one at a time. So, what happens when the second viewer changes the theme while the first viewer is still browsing the site?
  • Well, if there are concurrent viewers, each user gets a set of php files with the includes and hence themes selected by that user, with his/her theme preference stored in local cookies. If a user changes a theme, he gets the theme with the includes he selected, no? The php files are not locked, every users gets his copy served up. I mean, on first the call the user gets the theme set by the admin, but after that, if the user selects a different theme, the preference gets stored on his PC, and henceforward or until the cookie expires, or he selects a new theme he views the theme with his choice, not the administrator's. I've seen this in lots of sites offering different themes, and the site has a theme preview, so I can select the theme and view the content through that theme. Even if some data is stored in mySQL, well, mySQL manages concurrency, so there is no problem there.
  • There is only one database. Only one cache of images/thumbnails. All users will share these. You will have race conditions. The last user on the scene will overwrite anything other users still there have set.
  • The gallery is read-only for viewers, isn't it?. Viewers only read images, they do not write them, no? Sharing read-only files is no problem. There is very little chance of a gallery visitor having to write to a file, unless you have multiple admins. Even then, if they were to write to the same file, at the same time, the operating system would manage locking and concurrency. At the very worst, there would be a delay in grabbing the the file.

    Now, I don't know what zenphoto does behind the scenes but I can think of an analogy where there are concurrent writes to the database or the file system and yet there are no problems in logging users visits. In the first case (db)each user hit generates many writes to the db, in the second case (file system) each user generates many writes to the log files, and with much, much higher probability of concurrency than in a read-only gallery. yet, there are no poblems. The db or the OS manages the concurrency.

    Now again, I don't know the zenphoto code, that's why I asked the original question.
Sign In or Register to comment.