In-template razor logic to run macro if certain field has certain value
Hi,
I have a field on a document type that is true or false and specifies whether the admin wants to show something. That "something" is written in an XSLT macro/file. And my umbraco.library:RenderMacroContent() is not working within that XSLT file so I wan to try another way -- I was thinking perhaps right within the masterpage template checking this field's value and, if true, then write the macro call. How can I do this? Don't I need a script tag or something around the razor/cshtml logic?
Thanks so much for trying to help, Alex! I will pop that in right after I get one more reply from you -- I also need to know how syntactically to say, specifically, "if useGigya is true". Is it:
That field is a true/false checkbox. With either of those code snippets around the macro call I get this error when loading the page from the front end:
Compiler Error Message: CS0103: The name 'Model' does not exist in the current context.
Here is the complete snippet from the master masterpage template.
In-template razor logic to run macro if certain field has certain value
Hi,
I have a field on a document type that is true or false and specifies whether the admin wants to show something. That "something" is written in an XSLT macro/file. And my umbraco.library:RenderMacroContent() is not working within that XSLT file so I wan to try another way -- I was thinking perhaps right within the masterpage template checking this field's value and, if true, then write the macro call. How can I do this? Don't I need a script tag or something around the razor/cshtml logic?
Is basically what I want but I need the correct syntax and form.
Thanks, Garrett
Hi Garrett,
If you want to add if statement to the masterpage use this syntax:
Hope it will help.
Thanks,
Alex
Thanks so much for trying to help, Alex! I will pop that in right after I get one more reply from you -- I also need to know how syntactically to say, specifically, "if useGigya is true". Is it:
I'm sorry but I am all about XSLT and am just now learning Razor and CSHTML. The more complete and exact the answer, the better :)
Thanks again,
Garrett
Garrett, try
or
Depends on what type is "useGigya" field.
Thanks,
Alex
That field is a true/false checkbox. With either of those code snippets around the macro call I get this error when loading the page from the front end:
Here is the complete snippet from the master masterpage template.
Am I missing something? Do I need to import something before it to tell the template what Model is?
Thanks again,
Garrett
Hi Garrett,
Try this code:
Thanks,
Alex
By the way it's not Razor :) It's webforms syntax.
Error:
What am I missing? Thank you so much for your replies, Alex.
//Garrett
Add this line to the top of document -
BOOM. Thank you again, so much, Alex. I can now move forward with that Gigya implementation stuff, thanks to you.
Cheers,
Garrett
Glad to help you.
So this topic is solved, can you mark it solved?
Have a nice day, write more topics!
Thanks,
Alex
I don't know how to mark it as solved. Sorry!
//Garrett
is working on a reply...