Skip to content

multistore aware rendering #6

Description

writing views when you have multiple domains can be tricky when you know what is going to be custom to which domain but if you don't really know then either your code is fragile or the site maintainer has to do a lot of customization.

If the way that views/layouts/partials is determined could be tied to the store, it would be a lot easier, you could simply write your code the same way you would if there were only one store.

I think the solution lies in intercepting the creation of the ActionView::LookupContext and passing it an object that ActionView::LookupContext::ViewPaths can use to find the right file.

Then its "just" a matter of deciding how to identify the right file. It could work to prefix file names (_mystore_products.html.erb) but I feel this makes it difficult to identify store specific files (particularly if the store name is similar to a normal file name). Simply having a folder for each store plus one called "core" and one called "required". The files would be looked up first in the require directory (this way you could define things that cannot be store specific like "part of my super kewel network"), then the store directory, then the core directory and finally the the common rails directory.

Another approach would be to have named extensions - theme_required, theme_mystore, theme_core and go from there. The advantage here is that you could make a further enhancement that removed the requirement of having a store specific theme. Instead you could have theme_bluesteel and theme_magnum and the store would define which to use. This might necessitate adding a themes directory to the vendors directory for simplicity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions