Outputting a Node List from a MultiNode Tree Picker
I have a News content page that I would like only NewsArticles selected by a MultiNode Content Picker. I had thought I had looked up the correct way to implement this, but the script is not loading on the page. Here is my Razor. Any help would be appreciated. Thanks!
It's not just a specific DocType, it is selected articles to display under a specific page or NewsCategory. I have multiple NewsCategories, but in some cases I would like NewsArticles from one NewsCategory to also be displayed under a different NewsCategory as well. Do you understand?
I am stuck. Been working on this all day. My problem is I don't know how to get the value of the property of my multiNodePicker and then compair to see if it is on currentPage or Model and output the nodes selected with multiNodePicker in a list. Any help would be appreciated. Here is what I have now. The first part makes a separate list of "featureThisArticle" and it works fine. The "sidebarArticles" is the problem.
Is there another way to iterate through the values of the picker? I am using Umbraco 4.11 and the lambda is giving me a casting error; "Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type".
Neil, this loads on the page, but it's not pulling in any of the NewsArticles that had a NewsCategory node selected for that NewsArticle usind the MNTP. I believe this was the first way I had tried to accomplish this. Here is a screen capture of my tree and the NewsCategory that the NewsArticle should be listed on the newsZone "Rose-Hulman Commencement 2012".
Sorry, but this still isn't loading on the page, and I think I might not be explaining what I am trying to achieve well.
On any NewsArticle I would like to, using the MNTP select the page (the node of any NewsCategory) and have that NewsArticle display in a list on that selected NewsCategory.
Yep dont think im getting what your trying to achieve.
So this is what im now thinking - On every Category Page you have a side bar that needs to iterate through each NewsArticle and see it has been assigned to the NewsCategory via the NewsZone MNTP - that sound correct?
Ok hopefully this will work as expected, this iterates over the News nodes, looks into each NewsArticle and see's if the CategoryPage has been added to the NewsArticle, if so it shows the name of the newsArticle - This is for the sidebar only, you can add your code for the featured section to the top of it, i removed it for brevity
Ah yes that does suck, it would be handy to see, im sure its something or nothing causing it not to render anything out. i dont suppose you have access to the web.config then either to turn on umbracoDebugMode ?
at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at ASP._Page_macroScripts_NewsCategory_cshtml.Execute() in \\umbracoshare\prep\wwwroot\macroScripts\NewsCategory.cshtml:line 55
I now removed the () after Children and here is the exception:
at CallSite.Target(Closure , CallSite , Object ) at ASP._Page_macroScripts_NewsCategory_cshtml.Execute() in \\umbracoshare\prep\wwwroot\macroScripts\NewsCategory.cshtml:line 55
I can't understand why it wont work, i have my version here working fine, i can't even reproduce the error. Without being able to debug the razor code step by step in Visual Studio your gonna be a bit screwed bud
Do you not have a dev version you can debug? set Breakpoint and step through the code to see why its erroring? Are you making changes to a live site?
I was able to move past the error at line 55, by removing the "ToString()". GetPropertyValue() allready returns a string and I've allready checked to see if it HasValue("newsZones").
The next place it gets stuck at is line 58, with this error:
umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'ToXml'
You are correct Neil, we are using masterpages and webforms. I will change the datatype of the MNTP to use CSV. How does the syntax change for the code?
Outputting a Node List from a MultiNode Tree Picker
I have a News content page that I would like only NewsArticles selected by a MultiNode Content Picker. I had thought I had looked up the correct way to implement this, but the script is not loading on the page. Here is my Razor. Any help would be appreciated. Thanks!
Hi Steve,
Not sure but why are you using MultinodeTreePicker to display NewItems with a specific DocType ?
Why not Displaying those Specific DocType and using umbracoNaviHide to hide the ones you dont want to display ?
//fuji
It's not just a specific DocType, it is selected articles to display under a specific page or NewsCategory. I have multiple NewsCategories, but in some cases I would like NewsArticles from one NewsCategory to also be displayed under a different NewsCategory as well. Do you understand?
I am stuck. Been working on this all day. My problem is I don't know how to get the value of the property of my multiNodePicker and then compair to see if it is on currentPage or Model and output the nodes selected with multiNodePicker in a list. Any help would be appreciated. Here is what I have now. The first part makes a separate list of "featureThisArticle" and it works fine. The "sidebarArticles" is the problem.
Sorry, "newsZones" is the alias of the multiNodePicker
Hi Steve
Where is it breaking? Have you stepped through your code? I think i would do this:
then
Not tested but i would think at the minute sidebarAtricles would return a boolean as you have .HasValue() on the end?
Is there another way to iterate through the values of the picker? I am using Umbraco 4.11 and the lambda is giving me a casting error; "Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type".
I got the razor to save without errors by using uQuery, but the script still won't load on the page.
Hi Steve
I'll fire up an instance of 4.11 and mock what you have, the MNTP you have is that set to use CSV?
Am i right in thinking your structure looks like this:
Neil,
The picker is using xslt and you have the structure correct.Thank for your help.
When you say XSLT you mean the data is XML? not CSV yes?
Sorry, :) Yes, that is what I ment.
Ok give this a whirl
then iterate over them like this
Make sure the nodes are published, in some cases ive had to re publish the nodes as they havnt been picked up before
Neil, this loads on the page, but it's not pulling in any of the NewsArticles that had a NewsCategory node selected for that NewsArticle usind the MNTP. I believe this was the first way I had tried to accomplish this. Here is a screen capture of my tree and the NewsCategory that the NewsArticle should be listed on the newsZone "Rose-Hulman Commencement 2012".
Ok, so the Macro youve created holding the Razor code, where is that added? On the Template? On the News landing page via a RTE?
On the Template for NewsCategory.
Ok tested this and its showing each newsZone selected in each Newsarticle;
Sorry, but this still isn't loading on the page, and I think I might not be explaining what I am trying to achieve well.
On any NewsArticle I would like to, using the MNTP select the page (the node of any NewsCategory) and have that NewsArticle display in a list on that selected NewsCategory.
Yep dont think im getting what your trying to achieve.
So this is what im now thinking - On every Category Page you have a side bar that needs to iterate through each NewsArticle and see it has been assigned to the NewsCategory via the NewsZone MNTP - that sound correct?
Ok hopefully this will work as expected, this iterates over the News nodes, looks into each NewsArticle and see's if the CategoryPage has been added to the NewsArticle, if so it shows the name of the newsArticle - This is for the sidebar only, you can add your code for the featured section to the top of it, i removed it for brevity
Ive tested this within in my setup and it works fine, let me know how you get on.
It won't load in the page if the var AllNews = Model.AncestorOrSelf("News").Children()
only if I take off Children(), and then there is nothing pulled in.
Sorry, this has not been easy. I have no idea why it's not working.
Whats the top level Alias of News Node? I called mine 'News' yours may be different, just change the "News" to your alias
Yeah, I noticed that and had allready changed my code to be NewsHome. I didn't want to confuse you in my last post, but it still doesn't work.
Then im not sure whats going on, as mine displays correctly
Can you check the erro logs to see if its throwing an exception
No I don't have access to the install directory. Sucks right?
Ah yes that does suck, it would be handy to see, im sure its something or nothing causing it not to render anything out. i dont suppose you have access to the web.config then either to turn on umbracoDebugMode ?
Ok lets see if we can bubble up the exception in code
Ive wrapped it in a try catch block to see if it'll show the exception, try this
Oh and just a thought change:
to
as the brackets () at the end may be be the problem, ive had it in older instances, my version od Umbraco is 4.11.10
Here is the exception:
at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at ASP._Page_macroScripts_NewsCategory_cshtml.Execute() in \\umbracoshare\prep\wwwroot\macroScripts\NewsCategory.cshtml:line 55
I now removed the () after Children and here is the exception:
at CallSite.Target(Closure , CallSite , Object ) at ASP._Page_macroScripts_NewsCategory_cshtml.Execute() in \\umbracoshare\prep\wwwroot\macroScripts\NewsCategory.cshtml:line 55
Have you made sure your macro has this at the top?
These are the namespaces:
@using Umbraco.Core
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
Ok so it seems to be failing at line 55, which i think is the object 'dynamic' it doesnt like, can we change
to
see if it shows us anything else.
Other than that it has to be the way it iterates over the MNTP
Message: Cannot perform runtime binding on a null reference.
Must be a null refrence on the publishedNodeList, try this now ive added a check for nulls
Still the same error message.
Its defo something around line 55, take everything out of the else statement and see if it still errors
Yes, even if the else is empty.
I can't understand why it wont work, i have my version here working fine, i can't even reproduce the error. Without being able to debug the razor code step by step in Visual Studio your gonna be a bit screwed bud
Do you not have a dev version you can debug? set Breakpoint and step through the code to see why its erroring? Are you making changes to a live site?
Is there a way to have Visual Studio recognize Razor syntax? I was unaware of this. I'll look into how to do this. Thanks for all your efforts!
I was able to move past the error at line 55, by removing the "ToString()". GetPropertyValue() allready returns a string and I've allready checked to see if it HasValue("newsZones").
The next place it gets stuck at is line 58, with this error:
umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'ToXml'
Any ideas?
Im assuming your using master pages and the site is a web forms site, it may not be able to access MVC properties like .ToXml()
I would change the DataType MNTP to use CSV instead of XML, is their any specific reason why you need it to return XML?
You are correct Neil, we are using masterpages and webforms. I will change the datatype of the MNTP to use CSV. How does the syntax change for the code?
I inserted the code example from the MNTP component documentation page, but I get the error message "Cannot instantiate a DynamicNode without an id".
Here is what I am using to pull the CSV from the MNTP.
I'll have a look this evening, im in the UK so middle of the day here.
I think i cant reproduce your problem as my test site was MVC. im going to try and re create it this evening using WebForms and Masterpages.
Then i'll send over the code.
Can you confirm what version of Umbraco your using - you said 4.11, is that 4.11.0? do you know the minor version 4.11.??
It's 4.11.8
I am sorry, I thought I has said I was using Webforms earlier. Thanks for your help.
Has anyone got any suggestions? I am still unable to get this to work.
is working on a reply...