OK, i have writen my first plugin. I can display with the plugin a leaflet map with an gpx track.
The bleuprint of the page contains this field:
fields:
subheading:
type: text
tripname:
label: Reise
type: select
options: query
query: site.children.listed.template('trips').children
text:
type: blocks
fieldsets:
text:
label: Text
type: group
fieldsets:
- heading
- text
- list
- quote
additional:
label: Zusatz
type: group
fieldsets:
- line
- gpxtrackleaflet
media:
label: Media
type: group
fieldsets:
- image
- gallery
- video
gpxtrackleaflet is the block of my plugin.
This is the PHP Code from gpxtrackleaflet.php. This shows the map with the gpx track.
<?php if($block->gpxtrack()->isNotEmpty()): ?>
<div class="wrapper">
<div class="kirby-leafleat-map">
<div id="map"></div>
</div>
<script>
if (map != undefined) { map.remove(); }
var map = L.map('map').setView([51.505, -0.09], 13);
var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var gpx = '<?= $block->gpxtrack()->toFile()->url() ?>'; // URL to your GPX file or the GPX itself
new L.GPX(gpx, {
async: true,
marker_options: {
startIconUrl: '/assets/js/leaflet-gpx/pin-icon-start.png',
endIconUrl: '/assets/js/leaflet-gpx/pin-icon-end.png',
shadowUrl: '/assets/js/leaflet-gpx/pin-shadow.png'
}
}).on('loaded', function(e) {
map.fitBounds(e.target.getBounds());
}).addTo(map);
</script>
</div>
<?php endif; ?>
now, when i use $note->text()->toBlocks()->excerpt(280) to output an excerpt of the page, and the first block of the page is an gpx track, i can see this - that’s the content of the script in my gpxtrackleaflet.php file
Can i control the output? The excerpt should be created from the first block of text
Martin