The block displays the content but the value I need to return for example could be up 2 levels but if I reuse the block on a deeper node it could be 4 levels deep.
For now and for the purpose of simplicity, we could say the value I need is at the root of the site.
I have 2+ sites in the Umbraco so I can't use the first site the code finds should be the site I'm currently browsing.
I think I may have it. However be great if you could confirm if this is the correct approach just in case this causes other weird problems during the line. I used
var root = Umbraco.AssignedContentItem.Parent
Which seems to be doing what I need but if that's the correct approach I'm not so sure?
Model.Value missing in BlockList
Hi
I'm using a BlockList/BlockGrid. I need to get a value from a property up the tree from where the block is being called.
On normal pages I could do something like
But when I do this in a block component Value doesn't exist.
How do I retrieve a value from up the tree in a block?
Thank you
Is this component on the same node as the grid, or a different node.
Blocks have content items which are block items.
Maybe if you could explain exactly what you are attempting, someone can point you in the right direction
Hi Huw
The block is under views-partial-components.
I render it on a page a few levels deep using
The block displays the content but the value I need to return for example could be up 2 levels but if I reuse the block on a deeper node it could be 4 levels deep.
For now and for the purpose of simplicity, we could say the value I need is at the root of the site.
I have 2+ sites in the Umbraco so I can't use the first site the code finds should be the site I'm currently browsing.
I hope this gives more clarity and information?
Hi Jimmy,
Yes that explains a bit more. Are these nodes all descendants of the same root node, or do you have more than one root node.
If the value is at the site root you can just do something like
then use
siteroot.Value("aliasOfValue");
Hi Huw
The code worked but on the different site it didn't. It looks like siteRoot gets the first in the list of site roots and not the one I'm browsing?
Thank you
Ok, just change the firstordefault so it has an expression that checks the for the alias of the root node you require.
I'm not sure I follow.
If I change it to an alias name, like ws=> ws.Site.Alias would that not pick the same site each time the code is run?
Do you have multiple roots? could you perhaps post the layout of your nodes?
You could try Model.Root() but not sure exactly what you are attempting.
My site structure is
The same structure is followed throughout.
Site ** is where the properly is with a value I need for all sites. When site A,B,C,D load I want the value from that sites parent node.
I think I may have it. However be great if you could confirm if this is the correct approach just in case this causes other weird problems during the line. I used
Which seems to be doing what I need but if that's the correct approach I'm not so sure?
That will work as long as your page is only one level deep. But will fail if you have say
So you may be better using something like
is working on a reply...