1 (edited by namwebs 07-12-2016 16:19:57)

Topic: How to add custom ID to reporting page

Hi,

I would like to have an ID on the map output on a reporting form, to use custom CSS. Is it possible to do something like this in the Form structure section of the User interface? I have tried a few things but nothing worked. I'd like the '123' to be the dynamic-taxon_meaning_list from the URL. I thought maybe I could use something like <?php $_GET['dynamic-taxon_meaning_list'];?>.

<div id='123'>
[standard_params]
@allowSave=true
@linkToMapDiv=map
@taxon_list_id=15
@filter-my_records=0
[map]
@dataSource=library/occurrences/filterable_explore_list_mapping
@dataSourceLoRes=library/occurrences/filterable_explore_list_mapping
=Records=
[report_grid]
@dataSource=library/alice/filterable_explore_list_allspecies
@rowId=occurrence_id
@downloadLink=true
=Summary=
[report_grid]
@dataSource=library/taxa/filterable_explore_list
@downloadLink=true
@rowId=taxon_meaning_id
@linkFilterToMap=false
</div>

What I am trying to do is to hide the map for a few selected species. I've amended the query to exclude the data from the map. This works but now I want to hide the map and still show the grid so that it is clear that there are records. (These species automatically blur so there is no location data shown in the table.)

Any suggestions?

2

Re: How to add custom ID to reporting page

Hi

The [map] control accepts an option, divId, which enables you to set a static id on the map div. You'd write it

[map]
@divId=abc123

Note: an id should start with a letter if you want compatibility with html4

You can't write PHP in the Form Structure.

To achieve what you want will need some coding I think. If you are using the 'Reporting page (customisable)' we can override the prebuilt form that creates it (iform/client_helpers/prebuilt_forms/dynamic_report_explorer.php) to insert the option you desire.

Create a new php file in the prebuilt_forms folder with a nice name. File name, class name and function name need to be consistent in the following. In true IT style I'll call it foobar. I feel like a real developer now.

So, in foobar.php let us first create a new class that extends the dynamic report explorer.

<?php
require_once('dynamic_report_explorer.php');
class iform_foobar extends iform_dynamic_report_explorer {
}

In to this class we first need to insert a function to hook in to the list of forms that will be presented

  public static function get_foobar_definition() {
    return array(
      'title' => 'Foobar (customisable)',
      'category' => 'Reporting',
      'description' => 'Provides a foobar page.',
      'recommended' => true
    );
  }

Now we just need to modify the options going to the function in the parent class which produces the map and return its output.

  protected static function get_control_map($auth, $args, $tabalias, $options) {
    $divId = 'map';
    $divId .= (empty($_GET['dynamic-taxon_meaning_list']) ? '' : $_GET['dynamic-taxon_meaning_list']);
    $options['divId'] = $divId;
    return parent::get_control_map($auth, $args, $tabalias, $options);
  }

You could also use this function to check the value of the taxon and return nothing if you do not want to output the map at all.

Jim Bacon.