Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello guys,
I was wondering if there was any way to check if a certain macro gives an output like so:
@if(Model.Content.HasValue("expertBijBlog")){ <div class="hidden-xs hidden-sm hidden-md col-lg-3"><h3>Expert:</h3></div> }else if(MACRO HAS VALUE){ <div class="hidden-xs hidden-sm hidden-md col-lg-3"><h3>Gerelateerd:</h3></div> }
Could anyone help me out?
Thanks,
~Lex
Hi Lex
You can use RenderMacro method and then check if there some data after rendering, but it's not a good idea. Like that:
var macroOutput = Umbraco.RenderMacro("myMacroAlias"); @if(Model.Content.HasValue("expertBijBlog")){ <div class="hidden-xs hidden-sm hidden-md col-lg-3"><h3>Expert:</h3></div> }else if(!string.IsNullOrEmpty(macroOutput)){ <div class="hidden-xs hidden-sm hidden-md col-lg-3"><h3>Gerelateerd:</h3></div> }
Alex
Did you find out how to do it?
Do you have something to share with community?
Hi Alex,
I was quite busy and completely forgot about this post. I just looked at your solution and it works, except for a minor detail i added:
@{ var macroOutput = Umbraco.RenderMacro("Macro"); if(Model.Content.HasValue("Valuefield")){ <div class="hidden-xs hidden-sm hidden-md col-lg-3"><h3>Do this:</h3></div> }else if(!string.IsNullOrEmpty(macroOutput.ToString())){ <div class="hidden-xs hidden-sm hidden-md col-lg-3"><h3>Do That:</h3></div> } }
Glad that you solved it, thanks for sharing!
Have a nice day.
/Alex
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Checking if a MACRO gives output
Hello guys,
I was wondering if there was any way to check if a certain macro gives an output like so:
Could anyone help me out?
Thanks,
~Lex
Hi Lex
You can use RenderMacro method and then check if there some data after rendering, but it's not a good idea. Like that:
Thanks,
Alex
Hi Lex
Did you find out how to do it?
Do you have something to share with community?
Thanks,
Alex
Hi Alex,
I was quite busy and completely forgot about this post. I just looked at your solution and it works, except for a minor detail i added:
Glad that you solved it, thanks for sharing!
Have a nice day.
/Alex
is working on a reply...