2

I have a template in the project layer. Let's call it Author. That template inherits from a base template called _Author which is a template in the feature layer. Now I create a list of Authors in my Global folder. That list of authors is synchronized by the project layer.

Now I set up a template in the project layer called Article which inherits from a base template called _Article in the feature layer. The _Article template has a droplink field called Author which has a datasource that points to the Author folder in the Global folder.

Now I have a template in the feature layer that references an item in the project layer. What am I missing here? I have looked through Habitat to find a similar scenario, but I can't find any. Since this is a fairly common scenario I must be missing something.

This, however, seems to be the exact same scenario as with the site-specific datasources in Habitat where a pipeline is used to determine datasource settings. That setting then references a folder which is syncronised by the project layer. That way there is no reference between the rendering in the feature layer and the datasource in the project layer.

Does that mean that the solution is to create a similar pipeline solution for field datasources? If yes, I am surprised that this is not part of the Habitat solution...

Thanks

1 Answer 1

1

This is a common problem, but one that is simple to solve. What you need to do is instead of setting a direct path in your DropLink's source field, you want to do a "site" datasource.

Relative Datasource Query

There are a couple of ways you can do this. The source field of a drop link does support a query. So you could do a relative query, something like this:

query:./ancestor-or-self::*[@@templatename='SiteRoot']/Global/Authors/*

I have used this before and it works well. The only problem in a Helix solution is that you have technically only moved the dependency on the project layer from the Authors template to the Site Root template.

Look here for more information on what you can do with the source field on link field types.

1
  • Hi Richard, thanks - I get the concept of the site specific datasources and the site:authors part. I was just wondering about datasources on field types, as this hasn't been addressed in Habitat (yet). I was thinking the same about query datasources which will solve the problem. I have tried to avoid doing that in the past, but it looks like there is no way around it here. Thanks for your link. This is really helpful.
    – jonasag
    Commented Aug 7, 2017 at 15:00

Your Answer

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

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