Okey, I ended up with a property(ContentClassesProperty) in my ControlPanel. That way it is easy to choose what content types to hide.
Then i overrided the GetDefaultAddress() with this code:
Let me know if there is a better way of doing this :)
public override string GetDefaultAddress()
{
var address = base.GetDefaultAddress();
var classIds = this.GetUrlHiddenClassIds();
if (classIds.Count() > 0) {
var addressNames = new List();
var parents = this.GetParents(this.Parent);
for (int i = parents.Count() - 1; i >= 0; i--)
{
var parent = parents.ElementAt(i);
if (!classIds.Contains(parent.ClassId))
{
addressNames.Add(Utils.GetAddressFriendlyName(parent.Name));
}
}
addressNames.Add(Utils.GetAddressFriendlyName(this.Name));
address = string.Join("/", addressNames);
}
this.EnsureAddressUniqueness(address.ToLower());
return address;
}
public IEnumerable GetParents(NodeRelationPropertyValue parent)
{
while (parent.IsSet())
{
var hcParent = parent.Get();
parent = hcParent.Parent;
yield return hcParent;
}
}
public UniqueList GetUrlHiddenClassIds()
{
var list = new UniqueList();
var site = WAFRuntime.ContextSession.GetSite();
if (site is SOS.Site.SOSBarnebyer)
{
var sosSite = (SOS.Site.SOSBarnebyer)site;
if (sosSite.ControlPanel.IsSet())
{
var cp = sosSite.ControlPanel.Get();
list = cp.UrlHiddenContentClasses.GetClassIds();
}
}
return list;
}