Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5982989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:09:57+00:00 2026-05-22T22:09:57+00:00

I am creating a site which will have a desktop and a mobile theme.

  • 0

I am creating a site which will have a “desktop” and a “mobile” theme. I’ve two theme packages for this site: mysite.theme and mysite.mobile_theme. The mobile_theme is a stripped down version of the desktop theme, with new views and a reduced set of viewlets. I want to switch between these two themes based on the URL the site is visited from (i.e., mobile.mysite.com vs. http://www.mysite.com).

As the mobile and desktop themes will share a lot of code, mysite.mobile_theme descends from mysite.theme in the following ways:

1) mobile_theme GS skins.xml has a skin path based on the old theme, so the desktop theme’s CSS etc. is used:

<skin-path name="mysite.mobile_theme" based-on="mysite.theme">

2) IThemeSpecific marker subclasses the original one, so views which I’m not overriding for the mobile site fallback to the ones in mysite.theme:

from mysite.theme.browser.interfaces import IThemeSpecific as IBaseTheme
class IThemeSpecific(IBaseTheme):
    """Marker interface that defines a Zope 3 browser layer.
    """

3) I have registered various views in mysite.mobile_theme to override the certain ones in mysite.theme.

4) I’ve used generic setup to have different viewlet registrations for each theme.

At this stage, if I select mysite.mobile_theme in the “Default skin” option portal skins->properties, everything works correctly: my views are used and the viewlets settings from the mobile_theme’s GS profile are picked up correctly. So it appears the theme is set up correctly overall.

As mentioned above, however, I would like to swap between these two themes based on URL.

First, I swapped the “Default skin” back to “mysite.theme”. I then created an access_rule in the root on my Plone site, roughly following these instructions to select a skin based on URL. It’s at plonesite/access_rule and is set up as the access_rule for the plone site:

url = context.REQUEST.get('ACTUAL_URL', '')

if 'mobile' in url:
   context.changeSkin('mysite.mobile_theme', context.REQUEST)
else:
   context.changeSkin('mysite.theme', context.REQUEST)

I’ve also tried using context.REQUEST.set('plone_skin', 'mysite.theme') rather than calling context.changeSkin(...).

Using this setup, the viewlets displayed change correctly based on the URL I’ve used–so it looks like the skin is being changed at some point–but the mysite.mobile_theme’s view classes/templates are not being used in preference to mysite.theme’s. In summary:

  • If I call from a URL containing “mobile” I get mysite.theme’s views, but mysite.mobile_theme’s viewlet registrations.
  • Otherwise, I get mysite.theme’s views and mysite.theme’s viewlet registrations.

It looks like I might have to hook into the traversal mechanism to change it so if “mobile” is in the URL, the mysite.mobile_theme’s views registered against its IThemeSpecific are chosen rather than the mysite.theme ones, but I’m not sure this is correct nor how I’d go about this.

Can anyone give me some pointers?

UPDATE 3hrs after originally asking

To answer my own question (which I can’t do for another 5 hours due to SO’s rules):

“””
It would appear that you must patch much lower down in the stack to make this work. I looked at how it was done in plone.gomobile, and they monkeypatch the skin choosing code itself. See:

http://code.google.com/p/plonegomobile/source/browse/gomobile.mobile/trunk/gomobile/mobile/monkeypatch.py
“””

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:09:58+00:00Added an answer on May 22, 2026 at 10:09 pm

    You could use collective.editskinswitcher. Its main use case is to use the Plone Default theme on say edit.example.com and My Custom Theme on http://www.example.com. You can probably tweak its property sheet to fit your use case though.

    Since the ‘mobile theme’ use case is fairly common I would accept patches to make that easier; or I may work on that myself some time.

    (BTW, note that there is a fix-browser-layers branch that may help when you miss some items that are registered for a specific browser layer; seems ready to merge except that I would like to add some tests first.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently creating a site(php,css,html,ajax,MySql) which will have heavy user usage of space(regarding
I'm building a site which will provide product information in two languages: English and
I have made this batch script which will allow the user to enter a
I am creating a site on which content will be stored for several different
I have my main site kansasoutlawwrestling.com which will be using Codeigniter, and then I
I am creating a rails app which will help out businesses. These businesses have
I am creating a site which will make lots of searches and I need
I'm creating an site which allows users to upload photos. It's a linux server.
I'm creating a multi-tenancy web site which hosts pages for clients. The first segment
I am creating a voting system for a Q&A site project in which if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.