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
I need help selecting a folder in the content tree from a macro parameter using a Razor script. What am I missing?
I thought I could do something like:
var selectedFolder = Parameter.selectedFolder;
Here is my Razor:
@{ var i = 0; } @if (!String.IsNullOrEmpty(Parameter.slideFolder)) { var slideFolder = Parameter.slideFolder; <div class="slider"> @foreach (var item in slideFolder.Children.Where("Visible") ){ @item.name; if ( item.HasValue("image") ){ var location = (item.titleLocation != "") ? @item.titleLocation : "top-left"; <div class="slide" id="@i"> <h3 class="slideTitle @location">@item.name</h3> @if ( item.isVideo != true) { <a href="@item.imageLink"><img src="@item.image" title="@item.name" alt="@item.name" /></a> } else { <a class="video" href="@item.videoURL?autoplay=1&modestBranding=0&autohide=1&showinfo=0&rel=0&fs=0&theme=light"> <img src="/media/1362779/videooverlay.png" class="overlay" height="364" width="750" alt="Play Video for @item.name" /> <img src="@item.image" title="@item.name" alt="@item.name" /> </a> } <div class="caption">@item.copy</div> </div> i++; } } </div> }
The macro on the page won't load the script. I just get an error. I don't have anyway to turn on error reporting either.
Also, I have all the variables declared globally, I just didn't post them.
Hi Steve,
What version of Umbraco are you using? and next how does your first line in your Razor file looks like.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
or
@inherits umbraco.MacroEngines.DynamicNodeContext
Looking forward to hear from you.
/Dennis
I am using 6.1.6
First lines:
@using umbraco.MacroEngines @inherits umbraco.MacroEngines.DynamicNodeContext
Okay what if you are using the follow code below will this works for you.
@inherits umbraco.MacroEngines.DynamicNodeContext @using umbraco.MacroEngines @* Macro Parameters To Create, for this macro to work: Show:True Alias:slideFolder Name:Slide Folder ID Type:Content Picker *@ @{ var i = 0; } @if (Parameter.slideFolder != null) { @* Get the content folder as a dynamic node *@ var slideFolder = Library.NodeById(Parameter.slideFolder); foreach (var item in slideFolder.Children.Where("Visible") ){ @item.name; if ( item.HasValue("image") ){ var location = (item.titleLocation != "") ? @item.titleLocation : "top-left"; <div class="slide" id="@i"> <h3 class="slideTitle @location">@item.name</h3> @if ( item.isVideo != true) { <a href="@item.imageLink"><img src="@item.image" title="@item.name" alt="@item.name" /></a> } else { <a class="video" href="@item.videoURL?autoplay=1&modestBranding=0&autohide=1&showinfo=0&rel=0&fs=0&theme=light"> <img src="/media/1362779/videooverlay.png" class="overlay" height="364" width="750" alt="Play Video for @item.name" /> <img src="@item.image" title="@item.name" alt="@item.name" /> </a> } <div class="caption">@item.copy</div> </div> i++; } } }
Hope this helps,
Will this work even if my "slideFolder" is in with the content nodes, not the media library?
Yes it should, just to be sure that you are using Content picker as the type in the macro parameter.
Hope this works, else I will have another look,
Well, at least the script loads now, the slideshow isn't functioning though. Thanks for getting me this far!
Okay that is progress. Did you remember to includes the JavaScript files. I assume that the slider that you are using are using some JavaScript.
Else try to have a look in your browser console to see if you get some errors that can tell you why the slideshow isn't functioning.
Well, I got it working. I don't know why, but eventhough I had jquery loading in the of the template, I had to call the
Also, when you had me change the variable for slide folder to include "Library.NodeById(Parameter.slideFolder)", was that because the parameter using a ContentPicker returns the NodeId?
Yes the content picker returns an ID you can see the documentation here
Try to see the Razor Macro (DynamicNode) Example
https://our.umbraco.org/Documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Content-Picker
That is great that you got it working, I am glad that I could help you getting there.
I think that you should mark the question as solve so when people comes a cross this they can go directly to the solution and see what works for you.
Thanks for your help Dennis!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Selecting a Folder in the Content Tree From a Macro Parameter
I need help selecting a folder in the content tree from a macro parameter using a Razor script. What am I missing?
I thought I could do something like:
Here is my Razor:
The macro on the page won't load the script. I just get an error. I don't have anyway to turn on error reporting either.
Also, I have all the variables declared globally, I just didn't post them.
Hi Steve,
What version of Umbraco are you using? and next how does your first line in your Razor file looks like.
or
Looking forward to hear from you.
/Dennis
I am using 6.1.6
First lines:
Hi Steve,
Okay what if you are using the follow code below will this works for you.
Hope this helps,
/Dennis
Will this work even if my "slideFolder" is in with the content nodes, not the media library?
Hi Steve,
Yes it should, just to be sure that you are using Content picker as the type in the macro parameter.
Hope this works, else I will have another look,
/Dennis
Well, at least the script loads now, the slideshow isn't functioning though. Thanks for getting me this far!
Hi Steve,
Okay that is progress. Did you remember to includes the JavaScript files. I assume that the slider that you are using are using some JavaScript.
Else try to have a look in your browser console to see if you get some errors that can tell you why the slideshow isn't functioning.
/Dennis
Well, I got it working. I don't know why, but eventhough I had jquery loading in the of the template, I had to call the
Also, when you had me change the variable for slide folder to include "Library.NodeById(Parameter.slideFolder)", was that because the parameter using a ContentPicker returns the NodeId?
Hi Steve,
Yes the content picker returns an ID you can see the documentation here
Try to see the Razor Macro (DynamicNode) Example
https://our.umbraco.org/Documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Content-Picker
That is great that you got it working, I am glad that I could help you getting there.
I think that you should mark the question as solve so when people comes a cross this they can go directly to the solution and see what works for you.
/Dennis
Thanks for your help Dennis!
is working on a reply...