Partial view macro not working in RTE - Error is Failed to retrieve macro result for macro with alias
I have a simple partial view macro that I'm using to render YouTube embed code in to the RTE. When I add it though, I get an error "Failed to retrieve macro result for macro with alias". In the logs I get an error "Error loading Partial View (file: ~/Views/MacroPartials/YouTubeVideo.cshtml). Exception: System.ArgumentNullException: Value cannot be null. Parameter name: content"
Are you using MVC or Webforms? And have you tried having a look in the /App_Data/Logs file? It should contain more detailed information about the specific error related to the macro.
Is there a specific reason why you need to use a partial view macro in the RTE to show a YouTube video, instead of you use the built in embed function in the RTE. It can take YouTube videos.
One reason is I want to wrap the iframe embed code with a parent tag that makes the player responsive and fixes some formatting. Also, the built in embed insists on a width and height which I don't want.
Either way, it would be nice to know why it isn't working. I found a bug report of something that is fairly similar: http://issues.umbraco.org/issue/U4-3789
Thanks Dennis. The approach Chris is using is the same as mine though.
I have since discovered that when i add the macro to the RTE, if I check the network panel in firefox I can see umbraco trying to hit the following URL but it is getting a 404 (not found) back:
I have no problem to get this to work on the frontend of the website with this code snippet. I have added the macro paramter called videoID, as type textbox.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@if (Model.MacroParameters["videoID"] != null){
var fullLink = Model.MacroParameters["videoID"].ToString(); var youTubeId = fullLink.Split('=').Last();
But in the backend i will just get this macro Alias: YouTube in a yellow dotted box. Did you remember to add the parameter to the macro, and make sure that the alias is videoID. casing is very important herre.
Partial view macro not working in RTE - Error is Failed to retrieve macro result for macro with alias
I have a simple partial view macro that I'm using to render YouTube embed code in to the RTE. When I add it though, I get an error "Failed to retrieve macro result for macro with alias". In the logs I get an error "Error loading Partial View (file: ~/Views/MacroPartials/YouTubeVideo.cshtml). Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: content"
The macro code is:
Any ideas what is going wrong. It often works ok if I publish straight away but always fails on first load or when I preview it.
Using Umbraco version 7.1.4
Thanks!
Hi Ian
Are you using MVC or Webforms? And have you tried having a look in the /App_Data/Logs file? It should contain more detailed information about the specific error related to the macro.
/Jan
Using MVC. The more detailed message from the logs is the 2nd one shown above.
Thanks
Hi IanS,
Is there a specific reason why you need to use a partial view macro in the RTE to show a YouTube video, instead of you use the built in embed function in the RTE. It can take YouTube videos.
Hope this helps,
/Dennis
Hi Dennis
One reason is I want to wrap the iframe embed code with a parent tag that makes the player responsive and fixes some formatting. Also, the built in embed insists on a width and height which I don't want.
Either way, it would be nice to know why it isn't working. I found a bug report of something that is fairly similar: http://issues.umbraco.org/issue/U4-3789
Hi IanS,
Okay that make sense, try to see this thread about the same topic perhaps you can use the same approach as Chris. https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/61268-Umbraco-Grid-editor,-YouTube,-and-Bootstrap
Hope this helps,
/Dennis
Hi Ian
Ah, sorry missed that - Looked like the error one usually get's when seeing the error in the browser.
So you should probably just check if there has been set a value before trying to render the iframe code.
/Jan
Thanks Dennis. The approach Chris is using is the same as mine though.
I have since discovered that when i add the macro to the RTE, if I check the network panel in firefox I can see umbraco trying to hit the following URL but it is getting a 404 (not found) back:
/umbraco/backoffice/UmbracoApi/Macro/GetMacroResultAsHtmlForEditor?macroAlias=YouTubevideo&pageId=-1¯oParams%5B0%5D.key=videoID¯oParams%5B0%5D.value=1234567
Should this page exist? I can't find it in my installation although it is referenced in these scripts:
\umbraco\Js\umbraco.resources.js
umbraco\Js\umbraco.services.js
Seems like a common issue. Not sure if anyone has found a solution yet.
https://our.umbraco.org/forum/core/general/48713-Missing-backoffice-path
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53775-Not-getting-macro-params-in-macro-partial-view-from-custom-macro-parameter-datatype
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/53884-Insertupdate-macro-problem?p=1
Hi IanS,
I just think that your partial view macro file, just need to contain this snippet of code.
Hope this helps,
/Dennis
Thanks again. Have just tried that but unfortunately still getting the 404 error
Hi IanS,
I have no problem to get this to work on the frontend of the website with this code snippet. I have added the macro paramter called videoID, as type textbox.
But in the backend i will just get this macro Alias: YouTube in a yellow dotted box. Did you remember to add the parameter to the macro, and make sure that the alias is videoID. casing is very important herre.
Hope this helps,
/Dennis
Hi Dennis.
Yes I've added the parameter to the macro with the alias in the correct case and set as a textbox field. The 404 error I get is:
This file doesn't exist for me. Should it? If not, there must be some custom routing.
I've tried the latest build of Umbraco and this is still happening. Must be a bug then.
is working on a reply...