This post is pretty old, however I believe that I have found a solution. I started digging through the GlassV5Item.tt. When the template generates the inheritance string, it calls a method GetObjectInheritanceDefinition(DefaultNamespace, template, true, (string s) => AsInterfaceName(s))
. That method looks like this:
<#+
/// <summary>
/// Gets the inheritance string for the generated template
/// </summary>
/// <param name="defaultNamespace">The default namespace.</param>
/// <param name="template">The template to get the bases for.</param>
/// <param name="nameFunc">The function to run the base templates names through.</param>
/// <returns></returns>
public static string GetObjectInheritanceDefinition(string defaultNamespace, SitecoreTemplate item, bool includeLeadingComma, Func<string, string> nameFunc)
{
if (item.BaseTemplates.Count > 0)
{
return string.Concat(includeLeadingComma ? ", " : "",
item.BaseTemplates
.Select(bt => GetFullyQualifiedName(defaultNamespace, bt, nameFunc)) // select the name of the template with an 'I' prefix
.Aggregate( (total,next) => total + ", " + next) // basically a string.join(string[], '')
);
}
return "";
}
The offending section of code is the .Select( bt => GetFullyQualifiedName(defaultNamespace, bt, nameFunc))
.
The template makes no attempt to resolve the namespace of the base template. I resolved this by changing the select, as follows:
.Select(bt => GetFullyQualifiedName(bt.TargetProjectName, bt, nameFunc))
I'm not sure if TargetProjectName
is the best property to use, but since our project is Helix based, the TargetProjectName
name and the namespace of that project match.
The biggest key here, is that the inherited namespace is being derived from the item, not from a parameter that's hard-coded, as you called out as an issue.
I hope this helps!