Just wondering about best practice and peoples opinion really as I imagin it’s not a popular scenario and I can’t find much on the subject. I have 5 sites currently, which I’m rewriting in Yii. They’re all extremely similar at the minute and I’m creating them as themes on top of a main “skeletal” application, so the CSS, JS, images and some views override the main source.
This is all well and good, but I need mobile versions of these sites. This is essentially another theme, as it will do the same again, but my question is:
What’s the best way to provide mobile views, layouts and scripts that override the default ones (like a theme) without repeating all of them 5 times for the 5 mobile themes of the sites.
Thought number one passed through my mind, and was immedietly thrown out for the headaches it might cause later. To symlink 4 of them to one main on. This could get very awkward though, as when I do actually want to override something in a specific mobile theme, and not mobile wide, I can’t without directory structure changes :S.
Idea number two is to provide mobile views along side standard ones, this fits with the normal view and layout model and provides a good structure for overriding with themes. However, the code ends up being filled with:
If (mobile) viewName = 'mobile-product' else viewName = 'product'
Which again will be harder to maintain in the long run.
Thought three is the greatest and best, it is however, as far as I can see, not possible. Theme inheritance would solve my problem, if themes could be specified as $theme = ‘normaltheme.subtheme’ (parent.child) not a path alias) and apply the same overriding rules to this, just recursively, it would appear to solve everything.
If anybody has any other solutions I’d love to here them as I can predict a world of headaches with implementing this. If not, i’m going to give it a go over the next few days and may even submit it as a feature if it’s solid enough.