|
I have an idea for theming, but I would like some feedback before implementing it. By theme, I mean platform-specific views. Like if I want to display a mobile version of a site.
I will only be using one set of controllers and one set of models. The views will change depending on the theme. Since my controllers and models will not change, I would like to put them in the library and reference them there. If I can successfully do that then my modules will only have views and layouts. So why not use modules as my theme container? If the user is viewing on a mobile device, then I can intercept in a controller plugin and change the module on the fly. Or I can set up routing to go to a hostname specific route and redirect. Any feedback?
- Joe
|
|
On Thursday 10 Feb 2011 04:08:21 Joe Balancio wrote:
> I have an idea for theming, but I would like some feedback before > implementing it. By theme, I mean platform-specific views. Like if I want > to display a mobile version of a site. > > I will only be using one set of controllers and one set of models. The > views will change depending on the theme. Since my controllers and models > will not change, I would like to put them in the library and reference them > there. If I can successfully do that then my modules will only have views > and layouts. So why not use modules as my theme container? > > If the user is viewing on a mobile device, then I can intercept in a > controller plugin and change the module on the fly. Or I can set up routing > to go to a hostname specific route and redirect. > > Any feedback? > > ----- > - Joe I don't think you should use the module directory as a theme directory. Your models and controllers are application logic and should be in the app, not the library. If you only want to switch views for a mobile version, I'd do it somewhat different. Create a frontController plugin which hooks at an early stage and use WURFL (eg the Zend Http browseragent component) to look is a mobile switch should be set. If so, change your view extension from .phtml to .mobile.phtml. Then you can use your normal layout.phtml and layout.mobile.phtml and as well for the views: instead of index.phtml it would become index.mobile.phtml. Then you keep all your views at the right place and is it much easier to maintain. Regards, Jurian -- Jurian Sluiman Soflomo - http://soflomo.com |
|
On Thu, Feb 10, 2011 at 12:38 AM, Jurian Sluiman <[hidden email]
> wrote: > Create a frontController plugin which hooks at an early stage and > use WURFL (eg the Zend Http browseragent component) to look is a mobile > switch > should be set. > If so, change your view extension from .phtml to .mobile.phtml. Then you > can > use your normal layout.phtml and layout.mobile.phtml and as well for the > views: instead of index.phtml it would become index.mobile.phtml. I second Jurian's idea but it could probably be improved by extending the ContextSwitch action helper to support switching to a mobile context using the same logic that his plugin would use. However the action helper would let you control which actions will support a mobile view in case you are not theming the entire site. -- *Hector Virgen* Sr. Web Developer http://www.virgentech.com
--
Hector Virgen |
|
On Thursday 10 Feb 2011 20:01:22 Hector Virgen wrote:
> On Thu, Feb 10, 2011 at 12:38 AM, Jurian Sluiman > <[hidden email] > > > wrote: > > > > Create a frontController plugin which hooks at an early stage and > > use WURFL (eg the Zend Http browseragent component) to look is a mobile > > switch > > should be set. > > If so, change your view extension from .phtml to .mobile.phtml. Then you > > can > > use your normal layout.phtml and layout.mobile.phtml and as well for the > > views: instead of index.phtml it would become index.mobile.phtml. > > I second Jurian's idea but it could probably be improved by extending the > ContextSwitch action helper to support switching to a mobile context using > the same logic that his plugin would use. However the action helper would > let you control which actions will support a mobile view in case you are > not theming the entire site. > > -- > *Hector Virgen* > Sr. Web Developer > http://www.virgentech.com We use indeed this approach as wel at our company. The frontController plugin checks if we have a mobile device and if so, we can switch to a mobile layout. An extension of the contextSwitch lets us determine on controller/action base if we want a special view in case we have a mobile request. Regards, Jurian -- Jurian Sluiman Soflomo - http://soflomo.com |
|
In reply to this post by Hector Virgen
Ok that's understandable that the Controllers are application logic. My models, however, are not and can be reused across different projects. The models are associated with a web service class. Would it still make sense to keep them in the library?
I would ideally want to keep the themes in separate folders. This means I would use one module and have a themes folder containing the desktop theme or mobile theme. Then I can detect the platform in a frontcontroller plugin and stack a theme path.
- Joe
|
|
Le 11/02/11 04:01, Joe Balancio a écrit :
> > Ok that's understandable that the Controllers are application logic. My > models, however, are not and can be reused across different projects. The > models are associated with a web service class. Would it still make sense to > keep them in the library? > > I would ideally want to keep the themes in separate folders. This means I > would use one module and have a themes folder containing the desktop theme > or mobile theme. Then I can detect the platform in a frontcontroller plugin > and stack a theme path. > > ----- > - Joe From a file system & use perspective, it looks like you wrote kind of an extension. Maybe an extensions/ folder will be the place for you files as you could pack them under a given namespace to wrap your models, skins, etc. Magento uses this kind of design for its modules. Just write the according plugin to handle your extension and load them wherever you are. |
| Powered by Nabble | Edit this page |
