Hello dudes!. I am looking for some direction/samples on how I might go about retrieving a list of blog posts using the API specifically rather than using XSLT. I would be retrieving these from the Blog4Umbraco package.
I have done a lot of hunting around the forums and played with some options however what I have found doesn't seem to meet the requirements, which are these two simple things:
Only published content
Recursively iterate though sub folders/sub content
This acheives part of it, but it's not recursive so it simply returns me the years of the folders in the root level of the blog, in my case 2010, and 2011. Below is the code I have currently. Thanks for the help thus far.
Dim blogRoot As Node = New Node(1133)
Dim latestBlogs = From post
In blogRoot.Children
'Order By post.UpdateDatepost
For Each i In latestBlogs
Response.Write(i.Name)
Next
Hopefully my last question... so when running the following vb code...
Dim blogRoot As Node = New Node(1133)
Dim latestBlogs = From folder In blogRoot.Children _
From post In folder.Children _
Order By post.UpdateDatepost
I am getting an error telling me: "BC36593: Expression of type 'Object' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider." on the following line:
From post In folder.Children _
Entirely possible I didn't translate the code properly. Thanks again!
Well I don't know if the code compiles, I'm writing it in notepad :P
Looking at the source Nodes (the type of Node.Children) is not a generic list, it's a non-generic list. You may need to do node.Children.Cast<Node>() so it becomes a generic list and you can query against it
Add the .Cast<Node>() (or what ever the VB equivalent is) to each Children accessor
Got the issue sorted, and that gets me one level deeper to the months set of folders. Code as follows...
Dim blogRoot As Node = New Node(1133)
Dim latestBlogs = From folder As Node In blogRoot.Children _
From post In folder.Children() _
Order By post.UpdateDate _
Select post
For Each i In latestBlogs
Response.Write(i.Name & "<br>")
Next
Ok, then you'll just need to keep adding additional SelectMany statements to go from year folder to month folder to day folder (I forget how deep autofolders goes).
Using the API to Retrieve Recent Blog Posts
Hello dudes!. I am looking for some direction/samples on how I might go about retrieving a list of blog posts using the API specifically rather than using XSLT. I would be retrieving these from the Blog4Umbraco package.
I have done a lot of hunting around the forums and played with some options however what I have found doesn't seem to meet the requirements, which are these two simple things:
You can do something like this:
This acheives part of it, but it's not recursive so it simply returns me the years of the folders in the root level of the blog, in my case 2010, and 2011. Below is the code I have currently. Thanks for the help thus far.
Ah right, if you're using autofolders then you're going to have a bit of a problem.
Try this:
Hopefully my last question... so when running the following vb code...
I am getting an error telling me: "BC36593: Expression of type 'Object' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider." on the following line:
From post In folder.Children _
Entirely possible I didn't translate the code properly. Thanks again!
Well I don't know if the code compiles, I'm writing it in notepad :P
Looking at the source Nodes (the type of Node.Children) is not a generic list, it's a non-generic list. You may need to do node.Children.Cast<Node>() so it becomes a generic list and you can query against it
Add the .Cast<Node>() (or what ever the VB equivalent is) to each Children accessor
Got the issue sorted, and that gets me one level deeper to the months set of folders. Code as follows...
Ok, then you'll just need to keep adding additional SelectMany statements to go from year folder to month folder to day folder (I forget how deep autofolders goes).
SWEET! Got it. Thanks so much! Wish I could give you a "high five" but alas I have no karma. :-) Thanks man!
is working on a reply...