Copied to clipboard

Flag this post as spam?

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


  • Eric McDonald 16 posts 137 karma points
    Aug 21, 2016 @ 17:51
    Eric McDonald
    0

    How to total and display values from child pages by month

    Hi,

    Just new to the forum and im looking for a bit of guidance. I have a reports container page and which shows a grid of data with values of links to child pages. What I am trying to do is calculate the totals by month and display a tile that shows the total for each month. I have attached a screenshot of the page and also my partial view macro. I can get the values to add up but not by month. Any help or guidance would be greatly appreciated.

    enter image description here

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    

    @{ int MonthlyCatchTotal = 0; string sMonth = DateTime.Now.ToString("MMM");

    //Fetch the blogposts from a certain node id
    var latestCatches = Umbraco.Content(1157);
    
    
    foreach (var childPage in latestCatches.Children.Where("Visible").GroupBy)
    {
    
        int total = childPage.totalFish;
        MonthlyCatchTotal = MonthlyCatchTotal + total;
    
        <div class="dashboard-tile">
            <div class="dashboard-heading">
                <div class="row">
                    <div class="col-xs-3">
                        <i class="fa fa-folder-open fa-5x"></i>
                    </div>
                    <div class="col-xs-9 text-right">
                        <div class="huge">@MonthlyCatchTotal</div>
                        <div>Total Catches @sMonth</div>
                    </div>
                </div>
            </div>
            <a href="">
                <div class="panel-footer">
                    <span class="pull-left"></span>
                    <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                    <div class="clearfix"></div>
                </div>
            </a>
        </div>
    
    }
    

    }

  • Eric McDonald 16 posts 137 karma points
    Aug 23, 2016 @ 20:31
    Eric McDonald
    0

    Can anyone help with this issue?

Please Sign in or register to post replies

Write your reply to:

Draft