It should be translateable to Razor also - it's just checking to see what page it's being called from (if the URL contains macroResultWrapper) using the HTTP_URL ServerVariable. Unfortunately I know nothing about Razor yet so can't help you with the syntax. Sorry!
If true then it's the front-end of the site; if false then it's in the editor. You can then use this to render conditional content e.g.
@if (UmbracoContext.IsFrontEndUmbracoRequest)
{
<div>
Your macro for front-end
</div>
}
else
{
<div>
The stuff you want to show in the rich-text editor macro holder
</div>
}
different render for macros in editor
hii umbraco team.
in macro properties there is two checkbox:
Use in editor , Render content in editor
i think it will be grate to put another checkBox for :
diffrent render for editor
and multiLine textbox for HTML or even a simple image field.
a lot of macro can't render properly in editor ( scripts , css and so.. )
and even a diffrent image for editor render will be great..
thanks in advance.
Hi,
Check out this wiki article, in your macro you can detect if it's being displayed in the editor and show different content if desired: http://our.umbraco.org/wiki/how-tos/add-dummy-text-to-your-macros-in-the-richtext-editor
Hope this helps,
Tom
hii tom,
thanks for the quick replay..
that could be help.. but my macro is rendring cshtml(razor) , not xslt...
there is a translate for this if?
thanks again.
Hi,
It should be translateable to Razor also - it's just checking to see what page it's being called from (if the URL contains macroResultWrapper) using the HTTP_URL ServerVariable. Unfortunately I know nothing about Razor yet so can't help you with the syntax. Sorry!
-Tom
hii tom and thanks again.
till now i can't get it work..
i try to translate for razor like that :
if (umbraco.library.RequestServerVariables("HTTP_URL").Contains("macroResultWrapper"))
{}
it is not working..
i try also just to display the : umbraco.library.RequestServerVariables("HTTP_URL")
but i see nothing..
thanks for trying..
Hi,
This seems to work for me, hopefully for you as well:
-Tom
hii.. that exactlly what i am try to do...
not work for me...
i add this to the macro script - macroScript/macroName.cshtml
SLOVED..
change to : (HTTP_URL --> URL)
if (umbraco.library.RequestServerVariables("URL").Contains("macroResultWrapper"))
{
is render from editor
}
Now it's time to figure this out for Umbraco 7.
Sample url now:
/umbraco/backoffice/UmbracoApi/Macro/GetMacroResultAsHtmlForEditor?macroAlias=MyMacro
So (or use the umbraco library function):
Sure enough. That did the trick. Thanks!
For more modern Umbraco sites then you can check:
If true then it's the front-end of the site; if false then it's in the editor. You can then use this to render conditional content e.g.
is working on a reply...