Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jhon 87 posts 162 karma points
    Apr 10, 2018 @ 09:27
    Jhon
    0

    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.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    var node = Model.Content;
    
    
    }
    
    @foreach (var rejse in node.Children) {
    
    
                <div class="rejseContainer row">
    
    
                        <div id="toClear"></div>                        
                        <div class="rejseText col-md-7 col-lg-8">
                            <h1>@rejse.GetPropertyValue("titel")</h1>
    
                            <h2>@rejse.GetPropertyValue("subtitle")</h2>
                            <p style="max-width: 600px;">@rejse.GetPropertyValue("teaser")</p>
                        </div>
    
            </div>
    
    }
    

    see my document type.

    enter image description here

    output: enter image description here

    Content :

    enter image description here

  • Jhon 87 posts 162 karma points
    Apr 10, 2018 @ 09:45
    Jhon
    0

    Can anyone help me?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 10, 2018 @ 10:14
    Michaël Vanbrabandt
    0

    Hi Jhon,

    where and how do you call this partial view? Can you it to us?

    Thanks!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 10, 2018 @ 10:27
    Jhon
    0

    I attached template and partial view files.

    enter image description here

    enter image description here

  • Jhon 87 posts 162 karma points
    Apr 10, 2018 @ 10:43
    Jhon
    0

    Hi Michael,

    What is the mistake? Can you please share.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 10, 2018 @ 13:00
    Michaël Vanbrabandt
    0

    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:

    var nodes = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "theAliasOfYourNodes");
    

    Then using the foreach you can loop over these nodes and display the html into the frontend.

    Hope this helps!

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 11, 2018 @ 06:25
    Michaël Vanbrabandt
    0

    Hi Jhon,

    any news on this, did you solved the issue?

    Thanks!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 08:52
    Jhon
    0

    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) {

        <div class="rejseContainer row">
            <div class="top col-md-5 col-lg-4">        
        @{
            var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("image");
            if (typedMediaPickerSingle != null)
            {
                <p>@typedMediaPickerSingle.Url</p>
                <img src="@typedMediaPickerSingle.Url" style="width:200px" alt="@typedMediaPickerSingle.GetPropertyValue("alt")" />
            }
        } 
            </div>  
                <div id="toClear"></div>                        
                <div class="rejseText col-md-7 col-lg-8">
                    <h1>@rejse.GetPropertyValue("titel")</h1>
    
                    <h2>@rejse.GetPropertyValue("subtitle")</h2>
                    <p style="max-width: 600px;">@rejse.GetPropertyValue("teaser")</p>
                </div>
    
    </div>
    

    }

    Image is not displying , See my output:

    enter image description here

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 09:53
    Jhon
    0

    Can anyone please help me?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 10:12
    Michaël Vanbrabandt
    0

    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

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 10:21
    Jhon
    0

    Yes , I saw. see my datatype.

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 10:31
    Michaël Vanbrabandt
    0

    Jhon,

    And you have selected an image in the content node?

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 11:22
    Jhon
    0

    yes, see belowenter image description here

    I can not understand , why is not displaying.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 11:28
    Michaël Vanbrabandt
    0

    Ok think I found it:

    change:

    var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("image");
    

    to:

    var typedMediaPickerSingle = rejse.GetPropertyValue<IPublishedContent>("image");
    

    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

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 11:48
    Jhon
    1

    Michael ,

    Thank you very much for your kind guidance. It works fine.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 11:52
    Michaël Vanbrabandt
    0

    Hi Jhon,

    no problem! Glad I could help you out.

    Have a nice day!

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 12:02
    Michaël Vanbrabandt
    0

    Jhon,

    don't forget to mark the answer so that others with the same issue can find the solution.

    Enjoy Umbraco!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 12:16
    Jhon
    0

    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 :

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 13:05
    Michaël Vanbrabandt
    0

    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

  • Jhon 87 posts 162 karma points
    Apr 12, 2018 @ 13:29
    Jhon
    0

    Hi ,

    I wrote date function. What is the mistake here?

    see my code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{

    var rejse = Model.Content;

    }

    string dateCaption1 = "Startdate: " + @rejse.GetPropertyValue("startTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
    string dateCaption2 = "Enddate: " + @rejse.("endTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
    
                <div class="rejseInfo">
                <div class="rejseDate">
                <p style="padding-top: 4px; margin-bottom: 5px;">@dateCaption1</p>
                    <p>@dateCaption2</p>
                </div>
    
    
        <div class="bot">
            <h2>@rejse.GetPropertyValue("subtitle")</h2>
            <h1>@rejse.GetPropertyValue("title")</h1>
            <p style="font-weight: bold;">@rejse.GetPropertyValue("teaser")</p>
            <p>@rejse.GetPropertyValue("bodyText")</p>
        </div>
    </div>
    

    It is displying error.

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 12, 2018 @ 14:07
    Michaël Vanbrabandt
    0

    Hi Jhon,

    you need to place these 2 lines inside braces like:

    @{
    
    var rejse = Model.Content;
    string dateCaption1 = "Startdate: " + @rejse.GetPropertyValue("startTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
    string dateCaption2 = "Enddate: " + @rejse.("endTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
    
    }
    

    Hope this helps.

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 15, 2018 @ 11:38
    Michaël Vanbrabandt
    0

    Hi Jhon,

    did you solved your issue? Can you report back to the community? Thanks!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 07:19
    Jhon
    0

    Hi, Yes , i Placed it. It is displaying error. See my coding

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    @{

     var rejse = Model.Content;
     string dateCaption1 = "Startdate: " + @rejse.GetPropertyValue("startTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
    string dateCaption2 = "Enddate: " + @rejse.GetPropertyValue("endTime").ToString("d. MMMM yyyy", CultureInfo.CreateSpecificCulture("da-DK"));
    

    }

                <div class="rejseInfo">
                <div class="rejseDate">
                <p style="padding-top: 4px; margin-bottom: 5px;">@dateCaption1</p>
                    <p>@dateCaption2</p>
                </div>
    
    
        <div class="bot">
            <h2>@rejse.GetPropertyValue("subtitle")</h2>
            <h1>@rejse.GetPropertyValue("title")</h1>
            <p style="font-weight: bold;">@rejse.GetPropertyValue("teaser")</p>
            <p>@rejse.GetPropertyValue("bodyText")</p>
        </div>
    </div>
    

    See error:

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 07:31
    Michaël Vanbrabandt
    0

    Hi Jhon,

    could you translate the exception to english?

    The part from

    CS0103: .... 'CultureInfo'...

    Thanks!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 07:36
    Jhon
    0

    CS0103: The name 'CultureInfo' does not exist in the current context

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 07:43
    Michaël Vanbrabandt
    0

    Jhon,

    You're probably missing a "using namespace System.Globalization;" to include the lirbary for the CultureInfo.

    Have a nice day!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 07:50
    Jhon
    0

    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

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 07:58
    Michaël Vanbrabandt
    0

    Jhon,

    try to specify the returning type of your GetpropertyValue for both, eg:

     @rejse.GetPropertyValue<DateTime>("startTime")
    

    and

     @rejse.GetPropertyValue<DateTime>("endTime")
    

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 08:08
    Jhon
    0

    Hi Michael,

    It is displying error .

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Globalization;

    @{

     var rejse = Model.Content;
        string dateCaption1 = "Startdate: " +  @rejse.GetPropertyValue<DateTime>("startTime");
        string dateCaption2 = "Enddate: " +  @rejse.GetPropertyValue<DateTime>("endTime");
    

    }

                <div class="rejseInfo">
                <div class="rejseDate">
                <p style="padding-top: 4px; margin-bottom: 5px;">@dateCaption1</p>
                    <p>@dateCaption2</p>
                </div>
    
    
        <div class="bot">
            <h2>@rejse.GetPropertyValue("subtitle")</h2>
            <h1>@rejse.GetPropertyValue("title")</h1>
            <p style="font-weight: bold;">@rejse.GetPropertyValue("teaser")</p>
            <p>@rejse.GetPropertyValue("bodyText")</p>
        </div>
    </div>
    

    See error: I closed properly , why is it displying error.

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 08:10
    Michaël Vanbrabandt
    0

    Hi John,

    you removed the ToString part from your dates.

    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"));
    

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 08:24
    Jhon
    0

    Sorry , i added .

    again it is displying same error

    enter image description here

    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"));

    }

                <div class="rejseInfo">
                <div class="rejseDate">
                <p style="padding-top: 4px; margin-bottom: 5px;">@dateCaption1</p>
                    <p>@dateCaption2</p>
                </div>
    
    
        <div class="bot">
            <h2>@rejse.GetPropertyValue("subtitle")</h2>
            <h1>@rejse.GetPropertyValue("title")</h1>
            <p style="font-weight: bold;">@rejse.GetPropertyValue("teaser")</p>
            <p>@rejse.GetPropertyValue("bodyText")</p>
        </div>
    </div>
    
  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 08:29
    Michaël Vanbrabandt
    0

    Hi Jhon,

    is there a space in front of the datetime in .GetProperty< DateTime>(... ?

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 08:29
    Jhon
    0

    No space

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 08:31
    Michaël Vanbrabandt
    0

    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

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 08:33
    Jhon
    0

    See below my code

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 08:44
    Michaël Vanbrabandt
    0

    Jhon,

    remove the @ in front of both @rejse because you are in a razor block by using @{ ..... }

    Hope this helps.

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 08:45
    Jhon
    0

    what happened Michael?

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 08:47
    Michaël Vanbrabandt
    0

    What do you mean?

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 08:51
    Jhon
    1

    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.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 09:11
    Michaël Vanbrabandt
    0

    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

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 09:18
    Michaël Vanbrabandt
    0

    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

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 09:30
    Jhon
    0

    Hi Michael,

    The same code i have written another format, it is displaying error. What is the mistake here.

    enter image description here

    See output:

    Compiler Error Message: CS1928: 'System.Collections.Generic.IEnumerable

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 09:36
    Michaël Vanbrabandt
    0

    Jhon,

    because you do:

     Model.Content.Descendants().Where(....)
    

    This returns a list.

    So your string caption should be done inside your foreach for each rejse of your nodes.

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 09:42
    Jhon
    0

    Fine. Thanks

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 09:49
    Michaël Vanbrabandt
    0

    No problem!

    Have a nice day!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 10:12
    Jhon
    0

    Hi Michael,

    How to write two DocumentTypeAlias

    var node = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "PresseEkspert" || y => y.DocumentTypeAlias == "PresseForside" );

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 10:19
    Michaël Vanbrabandt
    0

    Hi Jhon,

    this way:

    var node = Model.Content.Descendants().Where(x => x.DocumentTypeAlias == "PresseEkspert" || x.DocumentTypeAlias == "PresseForside" );
    

    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

  • Jhon 87 posts 162 karma points
    Apr 16, 2018 @ 11:05
    Jhon
    0

    Sure. How can i mark the answer for this thread.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 16, 2018 @ 11:06
    Michaël Vanbrabandt
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft