2

We're thinking of following the Helix guidelines accordingly:

  • 1 Foundation module called "Favicon" that will be used in multiple websites in the same Sitecore instance
  • This feature is a field on the Home item, and is defined in a template that will be inherited by all websites
  • Each website would need to set (override) it's source separately (to the right folder in the Media Library) so that in the content editor the right folder is shown to select the image

How should we do this, without having to duplicate the "Favicon" feature for each site (essentially the Template that will be inherited)?

Screenshot of the field which source needs to be site specificly overriden

This is currently on Sitecore 7.0 (but with a planned upgrade to 8.2 in the near future, unfortunately after the go live of this specific website).

  • If its is for all websites why don't u add favicion to Foundation? – Dheeraj Palagiri Jan 3 '17 at 11:05
  • We're definitely open to doing that, but it will cause the same problem: if we inherit the template, we can't override the source to set the correct path for the media library. I will add it to the question. – Xuntar Jan 3 '17 at 11:07
8

You're going about it wrong. Or - I should say - not in accordance with Helix principles.

First and foremost, your idea of a common base template to be used on all websites is not recommended practice.

What Helix Documentation States

The architecture does not have the concept of a single common base template across all templates – which is a practice that is commonly discouraged as it will often lead to bloated items with unnecessary fields.

Source: http://helix.sitecore.net/principles/templates/inheritance.html#inheritance

What you should be doing instead, is something like the following:

  • Set up your "Favicon" as a Feature or Foundation. You have it as a Foundation module, which will be fine.
  • That will, in turn, give you a "Favicon" template. In Helix terminology, this is an Interface Template.

Defines an interface for solution logic to work against, for example by defining the fields that are used by a module’s logic or by simply being a template in the template inheritance hierarchy of an item. Can also be referred to as a base template.

Source: http://helix.sitecore.net/principles/templates/template-types.html#template-types

Now, for your individual websites - these are Projects in Helix terms. Projects hold Page Templates (and only Projects do this). So you can define a Home Page Template for each of your sites, have it inherit from your Favicon Foundation Interface Template and define a separate source on the Page Template.

Helix documentation describes this as:

To add editor managed settings to the site, modules should define templates which can be added as base templates to the site root item for the project layer module, or add settings items inside the site hierarchy.

Source: http://helix.sitecore.net/principles/multi-site/sites.html#sites

Summary

Make your Favicon Foundation module. Use the Interface Template you defined, and inherit from it on your individual Project Home Page templates. Alternatively, create a settings folder for each site, and place an item (Favicon Settings, for example) for each of the sites in the settings folder.

Since you need to override the field on the template level (not just a default value), the option with the settings folder is best suited for your particular scenario.

|improve this answer|||||
  • We understand what is meant by "Interface templates" now, but we can't use them because we need to override the "source" field of that Interface template (containing the Favicon item). We can create a settings folder - as you suggest - but that means there is no way of having code generation working for us in the Foundation module we created (since the items will be in the Project layer instead). Is it possible to have the items in the Foundation layer available so our code generation will work, and allowing us to override that "source" field? I will add a screenshot for clarity. – Xuntar Jan 3 '17 at 13:14
  • No. You need to leave the source field blank. If you need to control what folders in Media Library your users get access to (so only SiteA for example), set that up with permissions. This is not a Helix problem, this is just how Sitecore is wired. There may be some clever solutions out there that I am unaware of. – Mark Cassidy Jan 3 '17 at 13:23
  • It's not a permission issue as much as it is about user friendliness => they expect it to be prefilled to the right folder, because there are many websites and the same content editors have access to quite a few different websites (and different folders in the media library). I guess we're really looking for one of those "clever solutions" for this, but maybe the question was too unclear. Thanks a lot for your input though! – Xuntar Jan 3 '17 at 13:33
  • 1
    This reply is good in terms of structure. I would however consider the module naming itself. Favicon seems to be somewhat in the technical domain and modules should be named after the business need. Ask yourself: why do the business need a Favicon and then name it accordingly. Is it perhaps part of the identity of the site and thus a part of a Identity module? Also, this functionality definitely belongs in the Feature layer - not Foundation. – Eldblom Jan 3 '17 at 19:26
  • 3
    @Xuntar The layers determine the direction of dependencies, not the reusability. A feature module might be reusable too - although features are by nature more volatile than foundation modules. Simplified, think: foundation=API, feature=renderings. – Eldblom Jan 4 '17 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.