Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SS_Report and SideReport : how to?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1780 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    SS_Report and SideReport : how to? Link to this post

    I tried to create reports, but I don't see any of them.

    class DBReport_AquistatiProducts extends SideReport {
       
       function title() {
          return "Prodotti Acquistati";
       }
       
       function records() {
          return DataObject::get("Product", "Aquistato = 1", "Title");
       }
       
       function fieldsToShow() {
          return array(
             "Title" => array("NestedTitle", array("2")),
          );
       }
    }

    and under mysite/code/reports

    class CurrentOrdersReport extends SSReport {
    ...
    }

    Is there a guideline?
    Thank you

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: SS_Report and SideReport : how to? Link to this post

    In 2.3 these would appear automatically after doing a ?flush=1. In 2.4 you now have to register the reports you want to include in the cms via this line of code in your _config file.

    SS_Report::register("SideReport", "SideReport_NameOfReport");

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: SS_Report and SideReport : how to? Link to this post

    Hi Wilr,

    I have a class that extends the SS_Report. And I have this module that saves the report in a PDF format, its called DOMPDF module. Now, the thing is I want to create a custom template to render the report. Is this possible? If it is indeed possible, how do I go through this?

    Thanks in advance!

  • rwestera
    Avatar
    Community Member
    3 Posts

    Re: SS_Report and SideReport : how to? Link to this post

    And again - IS THERE A GUIDELINE?
    This seems to be horrendously underdocumented for something taking up a full tab in the CMS.
    The only tutorial I can find is http://doc.silverstripe.org/sapphire/en/reference/site-reports and that's completely out of date.

    So what needs to be done to add a report for 2.4?
    And is it SideReport or SS_Report now?

  • inCharge
    Avatar
    Community Member
    102 Posts

    Re: SS_Report and SideReport : how to? Link to this post

    rwestera, I know I'm replying to a months old post and you've probably switched to Drupal by now, but for anyone else trying to do this...

    This seems to be horrendously underdocumented for something taking up a full tab in the CMS.

    See http://api.silverstripe.org/2.4/cms/reports/SS_Report.html

    If you use the code as documentation, then you have everything you need.

    E.g. See cms/code/reports/BrokenLinksReport.php to see how to write a report. Search all php files for 'BrokenLinksReport' to see how it's utilised.

    This report allows users to download a csv of all users in the newsletter group:

    class UserReport extends SS_Report {

       function title() {
          return 'Users';
       }

       function sourceRecords($params, $sort, $limit) {

          return DataObject::get(
                 "Member"
                , "`Group`.`code`='newsletter'"
                , $sort
                , "inner join group_members on member.id = group_members.MemberId inner join `group` on group_members.GroupId = `group`.id"
                , $limit
             );
       }

       function columns() {

          $fields = array(
              'FirstName' => array(
                   'title' => 'First name'
                )
             , 'Surname' => array(
                   'title' => 'Surname'
                )
             , 'Email' => array(
                   'title' => 'Email'
                )
             );

          return $fields;
       }

    }

    To register a report in the CMS 'Reports' tab...

    SS_Report::register('ReportAdmin', 'UserReport', -19);

    I guess the number at the end determines the order they are shown in the menu.

    I think...

    SS_Report::register("SideReport", "SideReport_NameOfReport");


    ...is for reports that appear on the pages tab under 'Site Reports'.

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: SS_Report and SideReport : how to? Link to this post

    There is now an up to date tutorial for adding reports here: http://www.ssbits.com/tutorials/2011/adding-custom-filterable-reports-to-reportadmin/

    Hope that helps

    Aram

    1780 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.