the template Rejser Liste by which content nodes are these used? In your structure I see first Rejser and as a child 2018 and then the other childs which you want to display in the view.
If you call this partial view from the page Rejser it won't work because you access the direct children which in your case is the node 2018.
To display the other nodes you can use Descendants() where you filter on the Document Type alias of the nodes you want to view.
Thank you so much for your help i really appreciate it. It works fine. I am little busy with my exam . Therefore i can not chat with you. Sorry for the late reply.
Now i have a problem Media picker. I want to display one image from media picker not multiple image.
Thank you so much , It works fine. When i am learning Umbraco , I feel little bit hard but I am interesting to learn Umbraco .Thank you very much for your kind support.
Also Jhon, is it possible to set the answer for this thread and make a new thread for another issue? Because this thread is getting big and contains many different issues.
I can not see anything in my output
Hi ,
I have written this code but is not showing any error and i can not see out put.
see my document type.
output:
Content :
Can anyone help me?
Hi Jhon,
where and how do you call this partial view? Can you it to us?
Thanks!
/Michaël
I attached template and partial view files.
Hi Michael,
What is the mistake? Can you please share.
Hi Jhon,
the template
Rejser Liste
by which content nodes are these used? In your structure I see first Rejser and as a child 2018 and then the other childs which you want to display in the view.If you call this partial view from the page Rejser it won't work because you access the direct children which in your case is the node 2018.
To display the other nodes you can use
Descendants()
where you filter on the Document Type alias of the nodes you want to view.https://our.umbraco.org/documentation/reference/querying/ipublishedcontent/Collections#descendants
So on your Rejser page you can get the nodes by using:
Then using the foreach you can loop over these nodes and display the html into the frontend.
Hope this helps!
/Michaël
Hi Jhon,
any news on this, did you solved the issue?
Thanks!
/Michaël
Hi Michael,
Thank you so much for your help i really appreciate it. It works fine. I am little busy with my exam . Therefore i can not chat with you. Sorry for the late reply.
Now i have a problem Media picker. I want to display one image from media picker not multiple image.
See my coding
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var node = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "Arrangement");
}
@foreach (var rejse in node) {
}
Image is not displying , See my output:
Can anyone please help me?
Hi Jhon,
did you set the option to disable multi select on the media picker datatype?
https://our.umbraco.org/documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Media-Picker2#data-type-definition-example
Hope this helps!
/Michaël
Yes , I saw. see my datatype.
Jhon,
And you have selected an image in the content node?
/Michaël
yes, see below
I can not understand , why is not displaying.
Ok think I found it:
change:
to:
Because you are accessing the wrong object, you need to access the one from your foreach like the other properties.
Hope this helps!
/Michaël
Michael ,
Thank you very much for your kind guidance. It works fine.
Hi Jhon,
no problem! Glad I could help you out.
Have a nice day!
/Michaël
Jhon,
don't forget to mark the answer so that others with the same issue can find the solution.
Enjoy Umbraco!
/Michaël
I want to display Start date and end date in order by (startdate). How can i do thaat. Can you please provide any example in the doc.
Like that :
HI Jhon,
you mean the builtin published at and unpublished at dates or are you using custom date properties?
https://our.umbraco.org/Documentation/Reference/Querying/IPublishedContent/Collections#orderby
/Michaël
Hi ,
I wrote date function. What is the mistake here?
see my code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var rejse = Model.Content;
}
It is displying error.
Hi Jhon,
you need to place these 2 lines inside braces like:
Hope this helps.
/Michaël
Hi Jhon,
did you solved your issue? Can you report back to the community? Thanks!
/Michaël
Hi, Yes , i Placed it. It is displaying error. See my coding
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
}
See error:
Hi Jhon,
could you translate the exception to english?
The part from
Thanks!
/Michaël
CS0103: The name 'CultureInfo' does not exist in the current context
Jhon,
You're probably missing a "using namespace System.Globalization;" to include the lirbary for the
CultureInfo.
Have a nice day!
/Michaël
yes i added like that ,
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Globalization;
again it is displying error.
Compiler Error Message: CS1501: No overload for the 'ToString' method uses 2 arguments
Jhon,
try to specify the returning type of your
GetpropertyValue
for both, eg:and
Hope this helps!
/Michaël
Hi Michael,
It is displying error .
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Globalization;
@{
}
See error: I closed properly , why is it displying error.
Hi John,
you removed the
ToString
part from your dates./Michaël
Sorry , i added .
again it is displying same error
See coding
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Globalization;
@{
var rejse = Model.Content; string dateCaption1 = "Startdate: " + @rejse.GetPropertyValue< DateTime>("startTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK")); string dateCaption2 = "Enddate: " + @rejse.GetPropertyValue< DateTime>("endTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
}
Hi Jhon,
is there a space in front of the datetime in
.GetProperty< DateTime>(...
?/Michaël
No space
Its really hard to see the mistake, could you add the complete content of your partial view and format it nicely in this post?
/Michaël
See below my code
Jhon,
remove the
@
in front of both@rejse
because you are in a razor block by using@{ ..... }
Hope this helps.
/Michaël
what happened Michael?
What do you mean?
/Michaël
Thank you so much , It works fine. When i am learning Umbraco , I feel little bit hard but I am interesting to learn Umbraco .Thank you very much for your kind support.
Jhon,
no problem that's why we are the most friendliest community!
Also look at umbraco.tv where you find many videos for learning Umbaco!
Have a nice day!
/Michaël
Hi Jhon,
don't forget to mark the answer for this thread.
Have a nice day and keep on enjoying the Umbraco CMS!
/Michaël
Hi Michael,
The same code i have written another format, it is displaying error. What is the mistake here.
See output:
Compiler Error Message: CS1928: 'System.Collections.Generic.IEnumerable
Jhon,
because you do:
This returns a list.
So your string caption should be done inside your foreach for each
rejse
of your nodes./Michaël
Fine. Thanks
No problem!
Have a nice day!
/Michaël
Hi Michael,
How to write two DocumentTypeAlias
var node = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "PresseEkspert" || y => y.DocumentTypeAlias == "PresseForside" );
Hi Jhon,
this way:
Also Jhon, is it possible to set the answer for this thread and make a new thread for another issue? Because this thread is getting big and contains many different issues.
Hope this helps.
/Michaël
Sure. How can i mark the answer for this thread.
Hi Jhon,
under the post that you find the most complete answer for your issue you have a button
Mark as answer
.Have a nice day!
/Michaël
is working on a reply...