|
4 | 4 | Create a javascript variable for use in the function adding map markers. |
5 | 5 |
|
6 | 6 | Accepts Liquid array object and converts it to a javascript list |
7 | | - of dictionaries. |
| 7 | + of dictionaries (JSON). This will be used for chapters and events(posts) maps. |
| 8 | + If array of posts (events) is provided we get the event's address, latitude, |
| 9 | + longitude etc. from the FIRST sponsor object (if more than one are present |
| 10 | + for an event) Sponsor is a equivalent of a foreignkey for the event. |
| 11 | + One must remember though that sponsor is just a name not a reference to |
| 12 | + the sponsor object. |
| 13 | + This we find among sponsors using "where" filter as below. |
| 14 | + This is to avoid duplication of records in our yml section. |
8 | 15 |
|
9 | 16 | Parameters: |
10 | 17 |
|
|
25 | 32 |
|
26 | 33 | But it should be enough to use site.chapters or site.posts etc. |
27 | 34 | {% endcomment %} |
28 | | - |
29 | | - |
30 | | - |
31 | 35 | <script> |
32 | 36 | var locations = [ |
33 | 37 | {% for location in include.locations_array %} |
34 | | - {"title": "{{ location.title }}", |
35 | | - "meetupURL": "{{ location.meetup_link }}", |
36 | | - "URL": "{{ location.url }}", |
37 | | - {% if location.address %} |
38 | | - "address": "{{ location.address }}", |
| 38 | + {% if location.is_post %} |
| 39 | + {% assign host_sponsor_id = location.sponsors | first %} |
| 40 | + {% assign host_sponsor = site.sponsors | where:"obj_id", host_sponsor_id | first %} |
| 41 | + {% capture prefix %} |
| 42 | + "address": "{{ host_sponsor.address }}", |
| 43 | + "lat": {{ host_sponsor.lat }}, |
| 44 | + "lng": {{ host_sponsor.lng }}, |
| 45 | + {% endcapture %} |
39 | 46 | {% else %} |
40 | | - {% assign sponsor = location.sponsors %} |
41 | | - "address": "{{ sponsor.address }}", |
| 47 | + {% capture prefix %} |
| 48 | + "address": "{{ location.address }}", |
| 49 | + "lat": {{ location.lat }}, |
| 50 | + "lng": {{ location.lng }}, |
| 51 | + {% endcapture %} |
42 | 52 | {% endif %} |
43 | | - "lat": {{ location.lat }}, |
44 | | - "lng": {{ location.lng }} |
| 53 | + { |
| 54 | + {{ prefix }} |
| 55 | + "title": "{{ location.title }}", |
| 56 | + "meetupURL": "{{ location.meetup_link }}", |
| 57 | + "URL": "{{ location.url }}", |
45 | 58 | }, |
46 | 59 | {% endfor %} |
47 | 60 | ]; |
|
0 commit comments