asked    Darlene     2018-10-12       asp.net-mvc       15 view        1 Answer

[SOLVED] How to get descendants from current page in Umbraco 7?

I have a document type with alias dArticlesMain, and for this page I have the following structure.

dArticlesMain

  • dArticlesCategory1

    • Article1
    • Article2
    • Article3
  • dArticlesCategory2

    • Article1
    • Article2
    • Article3
  • dArticlesCategory3

    • Article1
    • Article2
    • Article3

I'm on dArticlesMain and i want to display all the descendants (Articles) and skip it's childrens (dArticlesCategory)

I have this code which display all the childrens (dArticlesCategory) and the descendants (Articles) also when i use the Article properties it's through an error.

<ul>
    @foreach(var page in Model.Content.Descendants())
    {
   <li><a href="">@page.Name</a></li>
   }
</ul>

I have got this code but i can't display by Article properties like articleText or articleImage.

 <ul>
@foreach(var page in Model.Content.DescendantsOrSelf().OfTypes("Article"))
    {
        <li><a href="">@page.Name</a></li>
    }
</ul>

  1 Answer  

        answered    Maxwell     2018-10-12      

I have figured it out, and here's my code...

   @{ 
        var rootNode = CurrentPage.AncestorOrSelf(1);
        var articlesParent = rootNode.Children("dArticlesMain").FirstOrDefault();

        <div class="row">
            @foreach (var article in articlesParent.Descendants("article").Where("Visible").RandomOrder())
            {
                <div class="col-sm-6 col-md-3">
                    <div class="thumbnail">
                        <a href="">
                            <img src="" alt="@article.articleName" />
                        </a>
                        <div class="caption">
                            <a class="h4" href="">@article.articleName</a>
                            @Umbraco.Truncate(article.articleFullText, 100)
                        </div>
                    </div>
                </div>
            }
        </div>
    }




Your Answer





 2018-10-12         Martina

Import entries to Umbraco Contour

Is there a way (the best would be an Excel importer) to import entries to an Umbraco Contour form? As far as I know, there is currently no way to import records to Contour out of the box I'm afraid. You'd have to use the Contour APIs and do it yourself, although there will be some complexities around items that have lists, like dropdown lists or multiple checkboxes. [XXX]
 umbraco7                     1 answers                     95 view
 2018-10-12         Katherine

Refreshing the page even if error message is shown

I'm using umbraco CMS and have a problem with my form.I've added error messagges if some of the fields are empty.If you click on "submit" the page is refreshing, and you need to scroll down again to the form section in order to view the error messages.I did a lot of changes in the form section (design) but can't find a solution to the problem.Has anyone had the same issue? Are you using the new UmbracoForms implementation? This sounds to me like a script or style issue. You should track when the user has submitted the form and after the submission (if there are errors pr...
 forms                     1 answers                     96 view
 2018-10-12         Vivien

What port does Courier for Umbraco use?

I have had a few problems setting up Courier for umbraco (v7).After a bit of trial an error I have discovered the destination server has all its ports blocked other than 80.Does anyone know what port I need to open up to get it to work? I'm pretty sure Courier just runs over port 80, as it's all web based. [XXX]
 umbraco                     1 answers                     97 view