so i am having quite a bit of difficulty to use the multinode tree picker in umbraco 7.6.4
i am using mvc, and have controllers, models and view divided.
I have setup my picker, and i can select blog posts in my page in backend.
But how do i get the data for the picked blog posts ? so far i can only get the properties which umbraco sets, and the name of the blog post.
But how do i get the data from the actual post ?
i am using viewbag and the data needs to get pulled in a partial view.
My Controller ( specificly TopMonthPicks, TopYearPicks )
public class MasterController : RenderMvcController
{
// GET: Master
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
// set frontpage.
var frontPage = CurrentPage.AncestorsOrSelf().FirstOrDefault(x => x.Level == 1);
ViewBag.Global = new Global()
{
MainMenu = GetMainMenu(frontPage),
Title = frontPage.GetPropertyValue<string>("pageTitle"),
SubTitle = frontPage.GetPropertyValue<string>("subPageTitle"),
CurrentPage = CurrentPage,
TopMonthPicks = frontPage.GetPropertyValue<IEnumerable<IPublishedContent>>("monthlyTopPicks"),
TopYearPicks = frontPage.GetPropertyValue<IEnumerable<IPublishedContent>>("yearlyTopPicks"),
};
}
First of all, are you planning do not use Umbraco in future?
Why did you decide to put all Umbraco data of the current page to the custom model class? You have this data in your razor code, don't need to pass it through controller one more time.
You can get all properties of blog posts:
var blogPosts = frontPage.GetPropertyValue<IEnumerable<IPublishedContent>>("monthlyTopPicks");
I can get the url for the blog post, the name and creation date.
But how do i for example get the image which i have added on the post ?
i have a property called "image" (single image) on the document type blogItem, which i want to get.
blog post picker - multinode tree picker - mvc
so i am having quite a bit of difficulty to use the multinode tree picker in umbraco 7.6.4
i am using mvc, and have controllers, models and view divided.
I have setup my picker, and i can select blog posts in my page in backend. But how do i get the data for the picked blog posts ? so far i can only get the properties which umbraco sets, and the name of the blog post. But how do i get the data from the actual post ?
i am using viewbag and the data needs to get pulled in a partial view.
My Controller ( specificly TopMonthPicks, TopYearPicks )
Hi Andre
First of all, are you planning do not use Umbraco in future?
Why did you decide to put all Umbraco data of the current page to the custom model class? You have this data in your razor code, don't need to pass it through controller one more time.
You can get all properties of blog posts:
Thanks,
Alex
that was me trying to get access to other data, i am not using it. I will definitely use umbraco.
but how do i write out the values in the view ?
Andre, you can render all blog posts names with this code:
i have this as an example.
I can get the url for the blog post, the name and creation date. But how do i for example get the image which i have added on the post ? i have a property called "image" (single image) on the document type blogItem, which i want to get.
How do i access this ?
Andre, you need something like that:
i get errors on hasvalue and getpropertyvalue,
Errors because your model properties are dynamics, can you use this code:
if they are dynamic, then what can i do ?
it does not appear i can use it, since i am using my own view models.
you can use strongly typed models, it's easy, just try code that I provided
it does not work, since it is a partial, should i add some sort of inherit at the top or ?
Yes, add please:
hmmm. i get a type or namespace could not be found...
btw. i am really appreciating this help you are giving ^^
EDIT... found this: @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
it results in quite a bit of errors ^^ but the same one. as you can see on the image.
Hi Andre
Can you paste the code as code, I would like to copy it and try to edit.
Thanks,
Alex
Its the same code you wrote to me.
Hi Andre
Did you solve this issue? Can you share with the community?
Thanks,
Alex
is working on a reply...