Skip to content

Fixes issue with macro rendering in an RTE when GUIDs are used for backoffice document routes#18691

Merged
Migaroez merged 2 commits intov13/devfrom
v13/bugfix/allow-macro-rendering-when-guid-is-used-in-backoffice-content-route
Mar 18, 2025
Merged

Fixes issue with macro rendering in an RTE when GUIDs are used for backoffice document routes#18691
Migaroez merged 2 commits intov13/devfrom
v13/bugfix/allow-macro-rendering-when-guid-is-used-in-backoffice-content-route

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Fixes: #16129

Description

Seems we do support backoffice routes using GUIDs in Umbraco 13, so this fixes an issue reported when making use of this with macro rendering. I've amended the request to accept either a GUID or an integer when looking up the content the macros is rendering on.

To Test:

  • Add a macro in an RTE that renders in the backoffice (e.g. using the simple Partial View Macro File below).
  • Amend the URL of the backoffice page that renders the document for editing, amending the integer ID with the page's GUID.
  • Make sure the macro renders and no error is thrown.
@inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage

<p>Test Macro Rendering</p>

@AndyButland AndyButland requested a review from Migaroez March 17, 2025 11:09
if (Guid.TryParse(pageId, out Guid pageIdAsGuid))
{
return umbracoContext.Content?.GetById(true, pageIdAsGuid);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndyButland would it be better to have Guid.TryParse first.. if page id is Guid there is no reason trying parsing to int.

if (Guid.TryParse(pageId, out Guid pageIdAsGuid))
{
    return umbracoContext.Content?.GetById(true, pageIdAsGuid);
} 

if (int.TryParse(pageId, NumberStyles.Integer, CultureInfo.InvariantCulture, out int pageIdAsInt))
{
    return umbracoContext.Content?.GetById(true, pageIdAsInt);
}

I guess int is mainly for legacy/fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually int is the expected case. For 13 back-office routes use integers.

Copy link
Contributor

@bjarnef bjarnef Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it will continue to that as well, but it pageId is already Guid it won't try parsing to int.

But I see your point as most backoffice routes in v13 are using int id, besides linking in custom extension or packages e.g.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also never fully supported Guid in v13 😅
#15289

@Migaroez Migaroez merged commit 5570583 into v13/dev Mar 18, 2025
19 checks passed
@Migaroez Migaroez deleted the v13/bugfix/allow-macro-rendering-when-guid-is-used-in-backoffice-content-route branch March 18, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants