I have followed the receipe in the documentation but seem to be stuck in the very final step: Rendering the Nivo Slider macro. I have tried to do it in Razor like so:
@Umbraco.RenderMacro("nivoSlider", new {nivoFolder="HomeSlider"})
HomeSlider being the media folder I have created and put my NivoSliderImage's in. What I get is the error message "Error loading MacroEngine script (file: NivoSlider.cshtml)".
If I debug this, it seems that the script is failing at the line
foreach (dynamic img in nodes.Children)
and I suspect this is because there are no nodes there. So I probably have specified the folder in a wrong way? An example of how the render the macro in razor in Umb 7 would be great to have as a reference!
I don't think this package works out of the box - It was released in 2011 and on the package page it says that the package is not compatible with version 4.7.1 of Umbraco...so I don't guess that it's compatible with versions higher than this out of the box either.
But perhaps you can share some of the code in it in here and perhaps it's farily easy to refactor the code?
2. Added a new media folder called 'HomeSlider' and then added 3 slides in it. Everything looking good, the property sheets of the slides work as expected.
3. Created a new partial view umbHomepageSlider for rendering the slider macro:
As you can see, this is where I specify the media folder 'HomeSlider' where the slides media is located. And I am not sure I did this right, if there maybe should be a path or an ID instead?
4. Finally, I've replaced the banner partial view of my home page (from the TXT Starter Kit) with my new slider partial view. Hence, my home page markup now looks like this:
And, what happens when I run the site in Visual Studio is that the macro-script fails on line 22:
foreach (dynamic img in nodes.Children)
with a NullReferenceException, because 'nodes' has no 'Children'. This leads me to believe that line 14 is the actual cause:
var nodes = @Model.MediaById(@Parameter.nivoFolder);
and that the 'nivoFolder' parameter I have given, 'HomeSlider', is wrong in some way. In other words, I probably don't understand exactly how Model.MediaById() work. (I'm relatively new to Umbraco and Razor.) So, if this is my only problem, it should be quite easy to fix, right?
Problems with Umbraco 7.2.0
I have followed the receipe in the documentation but seem to be stuck in the very final step: Rendering the Nivo Slider macro. I have tried to do it in Razor like so:
@Umbraco.RenderMacro("nivoSlider", new {nivoFolder="HomeSlider"})
HomeSlider being the media folder I have created and put my NivoSliderImage's in. What I get is the error message "Error loading MacroEngine script (file: NivoSlider.cshtml)".
If I debug this, it seems that the script is failing at the line
foreach (dynamic img in nodes.Children)
and I suspect this is because there are no nodes there. So I probably have specified the folder in a wrong way? An example of how the render the macro in razor in Umb 7 would be great to have as a reference!
Best,
Bendik
Hi Bendik
I don't think this package works out of the box - It was released in 2011 and on the package page it says that the package is not compatible with version 4.7.1 of Umbraco...so I don't guess that it's compatible with versions higher than this out of the box either.
But perhaps you can share some of the code in it in here and perhaps it's farily easy to refactor the code?
/Jan
Hi Jan
Ok, here's what I did:
1. Created the media type NivoSliderImage according to the docmentation. The structure now looks like this:
Tab: Image
Tab: Options
2. Added a new media folder called 'HomeSlider' and then added 3 slides in it. Everything looking good, the property sheets of the slides work as expected.
3. Created a new partial view umbHomepageSlider for rendering the slider macro:
As you can see, this is where I specify the media folder 'HomeSlider' where the slides media is located. And I am not sure I did this right, if there maybe should be a path or an ID instead?
4. Finally, I've replaced the banner partial view of my home page (from the TXT Starter Kit) with my new slider partial view. Hence, my home page markup now looks like this:
Now, the macro script NivoSlider.cshtml installed by the package is this:
And, what happens when I run the site in Visual Studio is that the macro-script fails on line 22:
with a NullReferenceException, because 'nodes' has no 'Children'. This leads me to believe that line 14 is the actual cause:
is working on a reply...