Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro Partials don't work on virtual pages #29

Closed
jaandrews opened this issue Oct 14, 2014 · 6 comments
Closed

Macro Partials don't work on virtual pages #29

jaandrews opened this issue Oct 14, 2014 · 6 comments

Comments

@jaandrews
Copy link

I am encountering issues with using macro partials in articulate. When visiting category pages, the macro errors out. This happens even when the macro partial has nothing but the inherits statement at the top. It does work as expected with the non virtual pages though.

I've also found that this is not an issue with the old way of handling Macros (using MacroEngines).

I am using v 1.0.3. Does 1.0.4 address this issue? The project I'm using it for is nearing launch, so I'm reluctant to risk the upgrade.

@Shazwazza
Copy link
Owner

1.0.4 is a minor release and only contains bug fixes, should be a very straight forward upgrade but of course you should test before you launch. Worth a try to see if it fixes it, can't say for sure. I won't have time to look into this for a few weeks.

@jaandrews
Copy link
Author

Thanks for the quick response. I tried upgrading, but that didn't resolve the issue. I'll just work around this issue with the old way of building macros for now.

@Shazwazza
Copy link
Owner

The underlying problem is that for any virtual pages, the ID assigned to it is 'virtual', meaning that there is no corresponding real node in umbraco.

The error comes from this line in UmbracoHelper:

m.renderMacro(attributes, umbracoPage.Elements, this.UmbracoContext.PageId.Value);

As you can see it's using this.UmbracoContext.PageId.Value as the current page id. On a virtual page this will be based on a simple algorithm and int.Max value. So when the old macro object tries to look this up it gives an error since that id doesn't exist.

I think in order for this to work (even though i still think there might be issues), we'll have to modify the Umbraco core. Unfortunately the way macros render is based on code made a century ago so it's difficult to work with.

I'll log an issue on the umbraco tracker for this.

@Shazwazza
Copy link
Owner

@Shazwazza
Copy link
Owner

Instead of using macros though, you can just use partial views directly... will be faster too. The only real reason to use macros nowadays is if you need support for your editors to insert macro parameters, which generally only pertains to the rich text editor or grid.

@Shazwazza
Copy link
Owner

This is fixed in umbraco now in rev: umbraco/Umbraco-CMS@73e9ff0

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

No branches or pull requests

2 participants