which mean the node variable is only setup in the first if statement - and doesn't exist outside of that if block.
so you need to move the delcleation out.
Personally I would do :
var node = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("linkPicker");
if (node == null || !node.Any()) {
node = ... the decendants stuff.
}
but
if is worth noting you are returning two diffrent types of things from these statements as written in your code
Model.Content.Decendents.Where(...) will return a collection of nodes (so and IEnumerable
I didn't ask what type of picker linkPicker was (my bad) - but i assume its a MultiNodeTreePicker in which case you should change the GetPropertyValue<IPublishedContent> bit to GetPropertyValue<IEnumerable<IPublishedContent>>
You don't always need the <>
also check the IEnumerable bit - i am just typing this in the forums and oftem miss spell that !
It is getting some error
Hi Michael,
Thanks for your help last time.
I have written this code , it is displaying some error. See below my code
see my output error:
See my document type:
Hi Jhon,
no problem.
For this thread I see you use
Model.HasValue
which doesn't exists.Make sure to always use
Model.Content
because its theContent
property that contains theIPublishedContent
object of your current page.Hope this helps!
/Michaël
Hi,
I think you need to change the code to :
and if you are not using the models from models builder
will need to become
Hi,
Yes i have written. See my code .
See error:
Compiler Error Message: The name 'node' does not exist in the current context
Hi
i think that is a issue with the variable scope.
in the if you have
which mean the node variable is only setup in the first if statement - and doesn't exist outside of that if block.
so you need to move the delcleation out.
Personally I would do :
but
if is worth noting you are returning two diffrent types of things from these statements as written in your code
Model.Content.Decendents.Where(...)
will return a collection of nodes (so and IEnumerableI didn't ask what type of picker linkPicker was (my bad) - but i assume its a MultiNodeTreePicker in which case you should change the
GetPropertyValue<IPublishedContent>
bit toGetPropertyValue<IEnumerable<IPublishedContent>>
You don't always need the <>
also check the IEnumerable bit - i am just typing this in the forums and oftem miss spell that !
Yes , The code is working.. I am using MultiNodeTreePicker. I want to check all process output. Thanks for you help.
is working on a reply...