I'm new to Umbraco and I and my other devleopers have been working through the learning curve for Umbraco. One question that keeps coming up and I can't seem to find an answer for is:
With Macro's can you nest macro? So that you can create macros that complete then move on to run other macros easily.
Any help or direction would be greatly appreciated.
With XSLT macro's you can actually do this, from within the XSLT you could call render macro. But it's not something that I would recommend.
If you have special needs like this, it's also very easy to just delve into the API and do whatever you'd like to do programmatically in a .net user control.
BUT you can only render other XSLT macros - you can NOT render .NET user-control macros. This is due to where the XSLT is processed in the ASP.NET page life-cycle. You can not "go back" after the Page_Load has executed (where most developers usually do their code-behind logic).
If you need to dynamically pull in macros from a .NET user-control (or any .NET class/code/method), then you can easily do that via the API (as Sebastiaan mentions).
But if you find yourself relying on nested Macros, then you might want to re-think what you are trying to achieve. If it's pulling out data, then XSLT Extensions might be a better way to go?
Nesting Macro
Hello,
I'm new to Umbraco and I and my other devleopers have been working through the learning curve for Umbraco. One question that keeps coming up and I can't seem to find an answer for is:
With Macro's can you nest macro? So that you can create macros that complete then move on to run other macros easily.
Any help or direction would be greatly appreciated.
Thank you
Lucein
With XSLT macro's you can actually do this, from within the XSLT you could call render macro. But it's not something that I would recommend.
If you have special needs like this, it's also very easy to just delve into the API and do whatever you'd like to do programmatically in a .net user control.
Some advice about nesting macros. Sebastiaan is right about rendering (nested) macros from an XSLT macro, here's how:
BUT you can only render other XSLT macros - you can NOT render .NET user-control macros. This is due to where the XSLT is processed in the ASP.NET page life-cycle. You can not "go back" after the Page_Load has executed (where most developers usually do their code-behind logic).
If you need to dynamically pull in macros from a .NET user-control (or any .NET class/code/method), then you can easily do that via the API (as Sebastiaan mentions).
But if you find yourself relying on nested Macros, then you might want to re-think what you are trying to achieve. If it's pulling out data, then XSLT Extensions might be a better way to go?
is working on a reply...