Reusable schema referenced pages are empty

2026/01/12 11:16 AM

Hello,

We have a reusable field schema for all links in our site. The idea is that we allow editors to specify the type of link and we display a different input type depending on the selection

This worked fine when the content item selector above only had 1 content type configured, PageType_Page. The generated property in all content types that use the reusable schema was

public IEnumerable<PageType_Page> Page { get; set; }

However, this is a new project and we are adding new page types. We added a page type called PageType_Homepage and when the content item selector was updated to now support multiple content types the code above changed to

public IEnumerable<IWebPageFieldsSource> Page { get; set; }

which is understandable.

We are using the ContentItemQueryBuilder to get content but now the Page property always has a count of 0, the referenced page is not being returned.

My initial question is if we are using reusable schemas in a way not intended? Although if we moved the property directly to a content type I fell like the same issue would happen

I have tried adding IncludeWebPageData() into my queries but that doesn't work
Has anyone run into this issue before whereby you want to have a content item that can link to pages of multiple types but the query is not returning the referenced pages?

Do we have to rethink our content model?


Environment

  • Xperience by Kentico version: [30.12.1]

  • .NET version: [8]

  • Execution environment: [SaaS]

Tags:
Content modeling

Answers

2026/01/12 1:04 PM

Yes, the page property on the Generated model has 0 items, its an IEnumerable, even though the content item is linked correctly to a page

Here is an example of a method where I'm getting a content item by a particular field value, i have similar methods for getting by Id, Guid, etc.

    public async Task<T> GetReusableContentItemByFieldAsync<T>(
        string contentTypeName,
        string field,
        string value,
        string localization,
        int maxLevel,
        CancellationToken cancellationToken = default) where T : new()
    {
        var builder = new ContentItemQueryBuilder()
            .ForContentType(
                contentTypeName,
                config =>
                {
                    config.Where(x =>
                    {
                        x.WhereEquals(field, value);
                    }).TopN(1);
                    config.WithLinkedItems(maxLevel);
                })
            .InLanguage(localization);

        var contentItemResult = await _executor.GetResult(builder: builder,
            resultSelector: container => _queryMapper.Map<T>(container),
            options: new ContentQueryExecutionOptions() { ForPreview = _channelContext.IsPreview },
            cancellationToken: cancellationToken);

        return contentItemResult.FirstOrDefault() ?? new T();
    }

Also a similar method to get the current page which is referencing CTA items which in turn reference the reusable schema

    public async Task<T?> GetCurrentPageAsync<T>(
        int maxLevel = ApplicationConstants.ContentDefaults.DefaultMaxLevel,
        CancellationToken cancellationToken = default) where T : new()
    {
        var currentPage = _webPageDataContextRetriever.Retrieve().WebPage;
        var builder = new ContentItemQueryBuilder()
            .ForContentType(currentPage.ContentTypeName,
                config => config.ForWebsite(currentPage.WebsiteChannelName)
                .Where(where => where.WhereEquals(nameof(IWebPageContentQueryDataContainer.WebPageItemID), currentPage.WebPageItemID))
                .WithLinkedItems(maxLevel))
            .InLanguage(currentPage.LanguageName);

        var pageResult = await _executor.GetWebPageResult(builder: builder,
            resultSelector: container => _queryMapper.Map<T>(container),
            options: new ContentQueryExecutionOptions() { ForPreview = _channelContext.IsPreview },
            cancellationToken: cancellationToken);

        return pageResult.FirstOrDefault() ?? default;
    }

When the LinkType is File or URL then these values are populated, which makes sense as they are just strings. The Page property is always empty

This is my reusable schema

	public interface IRsfhLinkFields
	{
		/// <summary>
		/// Code name of the reusable field schema.
		/// </summary>
		public const string REUSABLE_FIELD_SCHEMA_NAME = "Rsfh.LinkFields";


		/// <summary>
		/// LinkType.
		/// </summary>
		public string LinkType { get; set; }


		/// <summary>
		/// Page.
		/// </summary>
		public IEnumerable<IWebPageFieldsSource> Page { get; set; }


		/// <summary>
		/// URL.
		/// </summary>
		public string URL { get; set; }


		/// <summary>
		/// FileItem.
		/// </summary>
		public IEnumerable<ContentType_File> FileItem { get; set; }
	}

If I change the Page property to

public IEnumerable<PageType_Page> Page { get; set; } 

then it works as expected.

I'm guessing that I'm missing something in my queries but can't work it out. I even tried Claude with the documentation MCP server

To response this discussion, you have to login first.