Copied to clipboard

Flag this post as spam?

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


  • st 21 posts 111 karma points
    Aug 23, 2017 @ 12:27
    st
    0

    I have made a project site the content tree looks like this:

    Home
    - Project 1
    -- Document 1
    -- Document 2
    -- Document 3
    -- Document 4
    
    - Project 2
    -- Document 1
    -- Document 2
    -- Document 3
    -- Document 4
    
    - Project 3
    -- Document 1
    -- Document 2
    -- Document 3
    -- Document 4
    

    I am trying to make a partial view that: Displays all the documents in project 1, in project 1. Displays all the documents in project 2, in project 2. ... Displays all the documents in project 100, in project 100.

    The view i have made (see below) displays all the content from project 1 in all the projects. How to fix?

    I also want the href to link to the acual document. How to fix?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var selection = Model.Content.Site().FirstChild("project").Children("projectDocuments")
                            .Where(x => x.IsVisible());
    }
        @foreach(var item in selection){
        <div class="col-sm-3">
                        <div class="projectResource">
                            <h4>@Umbraco.Field("pageName")</h4>
                            <p>lorem bacon</p>
                            <a class="btn btn-primary btnButtom btn-lg" href="#">To the document &raquo;</a>
    
                        </div>
                    </div>
        }
    
  • Manish 373 posts 932 karma points
    Aug 23, 2017 @ 12:38
    Manish
    1

    You can fetch the id of current node for example if you are on project1 find the node id of this node if you are on project2 then find the node id of project 2 then find all it's child.

    var currentpageid = CurrentPage.Id;
    
    DocumentType nodeId = new DocumentType(currentpageid );
            foreach (Node childNode in nodeId.Children)
            {
    // your logic
    }
    
  • st 21 posts 111 karma points
    Oct 06, 2017 @ 10:32
    st
    0

    Thanks for the reply. I solved the issue getting children from the current page the following way:

    `@foreach (var item in Model.Content.Children()) {

    }`

Please Sign in or register to post replies

Write your reply to:

Draft