forked from Snck3rs/contao-leaflet-maps
Add map width and height to the content element.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
/bin/
|
/bin/
|
||||||
/demo/
|
/demo/
|
||||||
|
/assets/js/
|
||||||
|
|
||||||
coverage.xml
|
coverage.xml
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array(
|
$GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array(
|
||||||
'type' => array('type', 'headline'),
|
'type' => array('type', 'headline'),
|
||||||
'leaflet' => array('leaflet_map'),
|
'leaflet' => array('leaflet_map', 'leaflet_width', 'leaflet_height'),
|
||||||
'templates' => array(':hide', 'customTpl'),
|
'templates' => array(':hide', 'customTpl'),
|
||||||
'protected' => array(':hide', 'protected'),
|
'protected' => array(':hide', 'protected'),
|
||||||
'expert' => array(':hide', 'guests', 'cssID', 'space'),
|
'expert' => array(':hide', 'guests', 'cssID', 'space'),
|
||||||
@@ -20,3 +20,24 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array(
|
|||||||
),
|
),
|
||||||
'sql' => "int(10) unsigned NOT NULL default '0'"
|
'sql' => "int(10) unsigned NOT NULL default '0'"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_width'] = array(
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_width'],
|
||||||
|
'inputType' => 'inputUnit',
|
||||||
|
'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'),
|
||||||
|
'search' => false,
|
||||||
|
'exclude' => true,
|
||||||
|
'eval' => array('rgxp' => 'digit', 'tl_class' => 'clr w50'),
|
||||||
|
'sql' => "varchar(64) NOT NULL default ''"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_height'] = array(
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_height'],
|
||||||
|
'inputType' => 'inputUnit',
|
||||||
|
'options' => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'),
|
||||||
|
'search' => false,
|
||||||
|
'exclude' => true,
|
||||||
|
'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'),
|
||||||
|
'sql' => "varchar(64) NOT NULL default ''"
|
||||||
|
);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
|
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div id="<?php echo $this->mapId; ?>" style="width: 100%; height: 400px;"></div>
|
<div id="<?php echo $this->mapId; ?>" style="<?php echo $this->mapStyle; ?>"></div>
|
||||||
<?php if ($this->map): ?>
|
<?php if ($this->map): ?>
|
||||||
<script>
|
<script>
|
||||||
<?php echo $this->map; ?>
|
<?php echo $this->map; ?>
|
||||||
|
|||||||
@@ -57,7 +57,20 @@ class LeafletMapElement extends \ContentElement
|
|||||||
$GLOBALS['TL_BODY'][] = '<script>' . $map .'</script>';
|
$GLOBALS['TL_BODY'][] = '<script>' . $map .'</script>';
|
||||||
|
|
||||||
$this->Template->mapId = $mapId;
|
$this->Template->mapId = $mapId;
|
||||||
// $this->Template->map = $map;
|
|
||||||
|
$style = '';
|
||||||
|
$height = deserialize($this->leaflet_height, true);
|
||||||
|
$width = deserialize($this->leaflet_width, true);
|
||||||
|
|
||||||
|
if (!empty($width['value'])) {
|
||||||
|
$style .= 'width:' . $width['value'] . $width['unit'] . ';';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($height['value'])) {
|
||||||
|
$style .= 'height:' . $height['value'] . $height['unit'] . ';';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->Template->mapStyle = $style;
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user