Copied to clipboard

Flag this post as spam?

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


  • anil 17 posts 46 karma points
    Oct 22, 2014 @ 09:32
    anil
    0

    How to get property value of a document type & language list from language settings

    Hello All,

    Can any one help mw how can i get a propery calue of a data type that is used by many content nodes.

    I have a global root node under that i have many chiled nodes, all these chiled nodes are using same document type and i have 2 properties for this document type.

    1) I want to get those properties values from all the chiled nodes in code, how can i get that (using Umbraco 6.1.6)?.

    2) And how can i get list of languages from language settings?

    Thanks,

    Anil

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 22, 2014 @ 09:46
    Dennis Aaen
    0

    Hi Anil,

    I did have some questions before that I can try to help you with a solution.

    How did you get data out today, did you use XSLT or MVC razor or the old DynamicNode razor (Developer section files in the folder called Scripting files.)

    And when you ask how can i get list of languages from language settings? Would you like to just get an overview over which languages that you have installed or should these be visible on the site.

    Looking forward to hear from you.

    /Dennis

     

  • anil 17 posts 46 karma points
    Oct 22, 2014 @ 09:52
    anil
    0

    Hi Dennis,

    Thanks for your reply,

    I want to use MVC razor.

    Language i want to get list of languages names from a maco(MVC) and dispay this list in site.

    Thanks,

    Anil

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 22, 2014 @ 10:08
    Dennis Aaen
    0

    Hi Anil,

    To get the children of the global folder you can do something like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
    @if (CurrentPage.Children.Where("Visible").Any())
    {
        <ul>           
            @* For each child page under the root node, where the property umbracoNaviHide is not True *@
            @foreach (var childPage in CurrentPage.Children.Where("Visible"))
            {
                <li>
                    <a href="@childPage.Url">@childPage.Name</a>
                </li>
            }
        </ul>
    }

    This will give you the children of the global, if you insert the macro into the template that use for the global page. As you said you are using the same document type for all the languages fr es and so on depending on the alias of the document type you could also do it like this. Lets say my razor files should list children of a document type with the alias of NewsItem, then it possible for you to also do it like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
    @if (CurrentPage.NewsItems.Where("Visible").Any())
    {
        <ul>           
            @* For each child page under the root node, where the property umbracoNaviHide is not True *@
            @foreach (var childPage in CurrentPage.NewsItems.Where("Visible"))
            {
                <li>
                    <a href="@childPage.Url">@childPage.Name</a>
                </li>
            }
        </ul>
    }

    In the examples above you will get the name of the children. For you custom properties you will do like this.

    @childPage.PropertyAlias

    About your question for getting the list of languages names from the language folder in the settings section, I am not sure that is possible for you to do, unfortunately

    Hope this helps, and make sense.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft