CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Modify output of custom report (solved)
Pages: [1]

Author Topic: Modify output of custom report (solved)  (Read 632 times)

unclejustin

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
  • CiviCRM version: 4.3.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.3.6
Modify output of custom report (solved)
November 15, 2011, 07:27:55 am
I have a pretty simple custom report that shows a summary total using the code below. I'm trying to wrap a link around the "total" column's output. For example
Code: [Select]
<a href="somewhere.htm">123</a>
Below is the code that I have working so far. I think I need to override the buildRows function some how, but I don't know how. Can somebody point me in the right direction?

Code: [Select]
    //the columns (and thus headers) to display
  $this->_columnHeaders = array (
  'title'=>array ('title'=>'Interaction'),
  'count'=>array ('title'=>'# Recorded'),
    );

  // Report will now take the query and return the rows
  $this->buildRows ( $query, $rows);

    // format result set.
    $this->formatDisplay( $rows );
    $this -> doTemplateAssignment ( $rows ) ;
    $this -> endPostProcess ( $rows ) ;
« Last Edit: November 23, 2011, 01:06:27 pm by unclejustin »
-justin

Mark Tompsett

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 9
    • QualityTime Services Ltd
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.30-cll
  • PHP version: 5.3.23
Re: Modify output of custom report
November 23, 2011, 12:27:47 am
If I understand this correctly, I think you have to put your link code into the alter_display() function.
Take a look any of the existing report templates which include links to see how it's done, eg Activities.php.
The trick (in my experience) is to work out the array key of the column you need to change in order to make it a link.
Hope that helps.
Mark

unclejustin

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 2
  • CiviCRM version: 4.3.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.5
  • PHP version: 5.3.6
Re: Modify output of custom report
November 23, 2011, 01:05:48 pm
Yes! This is exactly what I needed. Turns out to be pretty simple too. Here's the code I ended up with for anyone else that needs it. You would obviously need to swap out the links for something real, but I think you get the picture.

Code: [Select]
// Change text values to link back to detailed report
function alterDisplay(&$rows) {
  foreach ( $rows as $rowNum => $row ) {
    // alter content
    $title = htmlspecialchars($row['title']);
    $count = htmlspecialchars($row['count']);
    $rows[$rowNum]['title'] = "<a href='/test'>$title</a>";
    $rows[$rowNum]['count'] = "<a href='/test'>$count</a>";
  }
}


This post was very useful also: http://artfulrobot.com/civicrm-custom-birthdays-report
« Last Edit: November 23, 2011, 01:07:27 pm by unclejustin »
-justin

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Modify output of custom report (solved)

This forum was archived on 2017-11-26.