If you want to use this piece of code anywhere in the site, you'd probably have to make sure to get to the correct node (Cases) in your tree structure, regardless of the current page.
So, if you'd have a single root node "Home", you're best bet is to use
var caseNode = Model.Content.AncestorOrSelf("HomeAlias").Children.First(x => x.IsDocumentType("CasesAlias")
and then use a foreach loop
foreach(var childNode in caseNode) {...}
I'm using typed objects here, CurrentPage is a dynamic object, so use whatever you prefer... but I'm sure you get the gist.
Of course I don't have any info on your "image" content, so bit hard to guess, but the problem here is that you're trying to work with dynamic "syntax" again, while my example is using typed IPublishedContent objects, so if your property on the image is called "caseImage", you'd need to use
Here's a good reference on typed vs dynamic, in case you want to have a better understanding. I'm not forcing you to use this or any, just that you know there's different ways to do it in Umbraco (I'm on the typed side if you'd wonder)...
Foreach loop on onepage
I got this onepage that I'm working on.
On the onepage, I have a section with a gallery with images. The images is links to subpages.
I tried this:
... It works, but when I'm adding the code again for another section, the code is taking every subpage in the root.
How am I gonna write this, so that it only takes the images in the subpage folder?
If I understand you correctly its working but you are getting all the nodes?
What you need to do is add a where clause and a lambda expression. Filtering out the other document types
Like so...
Hope that helps....
Hi Ayo,
I follow your thoughts with the filtering.
I'm just not sure, if I'm doing this right, because it's not working :(
you don't need node bit....
just CurrentPage.Where
remove
node.
Hi Ayo,
That leads me to this problem.
Sorry, I'm not used to work with Umbraco that much.
Just a little note....
isn't ok, you need to use the == comparison operator, = is an assigment operator
--Dirk
If you want to use this piece of code anywhere in the site, you'd probably have to make sure to get to the correct node (Cases) in your tree structure, regardless of the current page.
So, if you'd have a single root node "Home", you're best bet is to use
and then use a foreach loop
I'm using typed objects here, CurrentPage is a dynamic object, so use whatever you prefer... but I'm sure you get the gist.
-Dirk
Hi Dirk,
Thank you for the response, I've tried to work with your solution here, but I'm still kinda running into problems, am I doing something wrong?
I hope you can read it.
Yup, and probably my mistake.
--Dirk
Hi Dirk,
Haha, no props man. This seem to work, but now I seem to have a new problem.
It can't find my images that's uploaded in the underpages of Cases.
Of course I don't have any info on your "image" content, so bit hard to guess, but the problem here is that you're trying to work with dynamic "syntax" again, while my example is using typed IPublishedContent objects, so if your property on the image is called "caseImage", you'd need to use
to get the path of the image.
-Dirk
Hi Dirk
I'm know, sorry, I'm a little bad at explaining, so I'll try to illustrate it now.
Ok, just change
into
--Dirk
YES!
Thanks a lot for your time, Dirk!
It works!
Here's a good reference on typed vs dynamic, in case you want to have a better understanding. I'm not forcing you to use this or any, just that you know there's different ways to do it in Umbraco (I'm on the typed side if you'd wonder)...
http://24days.in/umbraco-cms/2015/strongly-typed-vs-dynamic-content-access/
is working on a reply...