Copied to clipboard

Flag this post as spam?

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


  • Manasa 80 posts 201 karma points
    Nov 13, 2014 @ 12:53
    Manasa
    0

    Macro to fetch property values.

    Hi,

     

    I have used articulate package for blog. I wanted to know how to write partial view to fetch data or value of properties. Below is the screenshot:

     

    These properties are in Archive.

    var root = Umbraco.TypedContentAtRoot().Single(x => x.DocumentTypeAlias == "Articulate");

     

        <h1>@root.GetPropertyValue("name")</h1>

            <h1>@root.GetPropertyValue("blogDescription")</h1>      

     

    Iam able to fetch property values for blog but not for archive.

    Thanks,

    Manasa

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 13, 2014 @ 19:41
    Dennis Aaen
    100

    Hi Manasa,

    I have had time to have a look at this, and try to find a solution for you, and I think for  you.

    Try to use this code and see if it works for you.

    @{
        var root = Umbraco.TypedContentAtRoot().DescendantsOrSelf("ArticulateArchive").FirstOrDefault();
       
        <h1>@root.GetPropertyValue("name")</h1>
        <h1>@root.GetPropertyValue("blogDescription")</h1>
    }

    Hope this helps,

    /Dennis

  • Manasa 80 posts 201 karma points
    Nov 14, 2014 @ 10:33
    Manasa
    0

    Thanks a lot Dennis :).

     

    It worked

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 14, 2014 @ 10:40
    Dennis Aaen
    0

    Hi Manasa,

    You are welcome. Glad that I could help you.

    By the way please remember to mark the question as solved :-).

    /Dennis

  • Manasa 80 posts 201 karma points
    Nov 14, 2014 @ 11:17
    Manasa
    0

    Dennis,

     

    If i gotta loop for multiple times, how can I do it. Coz when I tried 

     

     @{

           

            var blogs = Umbraco.TypedContentAtRoot().DescendantsOrSelf("ArticulateRichText").FirstOrDefault();

            foreach(var blog in blogs) { 

           <h4><a href="@blogs.Url" target="_top">@blogs.Name</a></h4>

         <p>@blogs.GetPropertyValue("publishedDate")</p>

            <p>@blogs.GetPropertyValue("excerpt")</p>

        }

        }

     

    I get a error. foreach statement cannot operate on Umbraco.Core.Models.IPublishedContent .

     

    Thanks,

    Manasa

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 14, 2014 @ 11:39
    Dennis Aaen
    0

    Hi Manasa.

    Try this snippet of codes and see if it gives you the results that you want.

    @{

        var blogs = Umbraco.TypedContentAtRoot().DescendantsOrSelf("ArticulateArchive").FirstOrDefault();
           
            foreach (var blog in blogs.Children.Where(x => x.IsVisible())){
                <h4><a href="@blog.Url" target="_top">@blogs.Name</a></h4>
                <p>@blog.GetPropertyValue("publishedDate")</p>
                <p>@blog.GetPropertyValue("excerpt")</p>

            }
    }

    Hope this helps,

    /Dennis

  • Manasa 80 posts 201 karma points
    Nov 17, 2014 @ 11:30
    Manasa
    0

    Cooll... Worked.. Thanks a lot :)

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 17, 2014 @ 11:31
    Dennis Aaen
    0

    Hi Manasa,

    You´re welcome glad that I could help you.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft