5

In a feature for an event I have 2 templates: Speaker and Session. A session has a speaker, so in the session template we have a field to select a speaker.

As project templates, I also created speaker and session and they inherit from the feature templates (and some others to make them a worthy page). We did opt to set the data for these items on the template itself as they will never be personalized or anything like that and it makes things quite a bit easier (for dev and content editor).

But then I have an issue if I want to stick to the Helix guidelines: the "speaker" field in my session (feature) template will need a source to please the editors. In that source, I cannot use an exact location so I use a query (which is fine) but I would like/need to use the template that is allowed. But that I cannot do because if I follow Helix I should not be aware of the template (as that is on project level).

I know some people will say: datasource everything - don't put it on your template.. that would fix this issue but create 2 new ones:

  • How do I explain my editor that he needs to create at least 2 items just to add a speaker or a session?
  • How do I create a list overview of all sessions of a speaker? I can search for all session item that have that speaker selected, but that would give me the datasources and not the items I can link to.

I don't want to start a(nother) discussion here on datasourcing everything or whether Sitecore is missing some functionality on base-templates to fully incorporate Helix (let's do that on Slack) but how should I get around this? I actually just want to put the source on a (feature) field...

2
  • 3
    Check out this branch which enables site specific datasources on fields. Will be integrated into Habitat when we have time. github.com/Sitecore/Habitat/pull/292
    – Eldblom
    Apr 20, 2017 at 12:00
  • Does anyone have an actual answer for the record, one that is not just a link? :-) Apr 29, 2017 at 0:24

1 Answer 1

1

I think your best answer here is to use a coded datasource for the speaker field in feature template. And in that code define some vague logic of where the speaker list will be located. i.e. $site/SiteData/Speakers/

You could also use an IsDerived item extension find the items that are derived from your feature template, knowing that your project template has to be derived from your feature template.

    public static bool IsDerived(this Item item, ID templateId)
    {
        if (item == null)
        {
            return false;
        }

        return !templateId.IsNull && item.IsDerived(item.Database.Templates[templateId]);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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