aboutsummaryrefslogtreecommitdiffstats
path: root/docs/customising/cobrand-module.md
blob: fb771ab26e12975443c69481699b181a9f668467 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
layout: page
title: Customising with a Cobrand module
---

# Cobrand module

If you need customistation beyond what templates, configuration variables, and
translations can offer, then you will have to have a Cobrand module. These are
automatically loaded according to the current Cobrand and can be found in
`perllib/FixMyStreet/Cobrand/`. There is a default Cobrand (`Default.pm`)
which all Cobrands should inherit from. A Cobrand module can then override any
of the methods from the default Cobrand.

Many of the functions in the Cobrand module are used by FixMyStreet in the UK
to allow the site to offer versions localised to a single authority and should
not be needed for most installs. Listed below are some of the options that
can be changed:

* language_override

    Return a language code string from this function if you wish your cobrand
to always be in a particular language, rather than try and work it out from the
domain name or the browser’s settings.

* add_response_headers

    Any extra headers you wish to send with your HTTP responses. For example,
    fixmystreet.com uses this to send a Content-Security-Policy header.

* on_map_default_max_pin_age

    How far back to go by default showing pins on your around map.

* areas_on_around

    If you would like to plot the boundaries of MapIt IDs on an around page
(not just reports page), you specify them here.

* pin_colour

    This can be used if you wish to specify different pin colours depending upon
some aspect of the report - its state, category, and so on.

* pin_new_report_colour

    What colour to use for the pin when reporting a new issue.

* geocode_postcode

    This function is used to convert postcodes (zip codes, etc.) entered into a
latitude and longitude, if there's a different way from your geocoder of doing so
(e.g. a MapIt install). If the text passed is not a valid postcode then an
error should be returned. If you do not want to use postcodes, just do not define
this function.

    If the postcode is valid and can be converted then the return value should
look like this:

        return { latitude => $latitude, longitude => $longitude };

    If there is an error it should look like this:

        return { error => $error_message };

* find_closest and find_closest_address_for_rss

    These are used to provide information on the closest street to the point of
the address in reports and RSS feeds or alerts.

* allow_photo_upload

    Return 0 to disable the photo upload field.

* allow_photo_display

    Return 0 to disable the display of uploaded photos.

* remove_redundant_areas

    This is used to filter out any overlapping jurisdictions from MapIt results
where only one of the authorities actually has responsibility for the events
reported by the site. An example would be a report in a city where MapIt
has an ID for the city council and the state council (and they are both the
same MapIt area type) but problems are only reported to the state. In this case
you could remove the ID for the city council from the results.

    With the new bodies handling, a better way to handle this would be to simply
have a body that only covered the state council administrative area.

* short_name

    This is used to turn the full authority name returned by MapIt into a short
name.

* send_questionnaires

    By default, FixMyStreet [sends questionnaires]({{ "/running/surveys" | relative_url }})
    (sometimes called _surveys_) four weeks after a user submitted a report. The
    questionnaire encourages them to update the 
    <a href="{{ "/glossary/#state" | relative_url }}" class="glossary__link">state</a>
    of the report. Return 0 to disable this feature so that surveys are never
    sent.