Add map width and height to the content element.

This commit is contained in:
David Molineus
2015-01-06 21:40:53 +01:00
parent adc8de55ae
commit 98078df0eb
4 changed files with 38 additions and 3 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
/vendor/
/bin/
/demo/
/assets/js/
coverage.xml

View File

@@ -2,7 +2,7 @@
$GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array(
'type' => array('type', 'headline'),
'leaflet' => array('leaflet_map'),
'leaflet' => array('leaflet_map', 'leaflet_width', 'leaflet_height'),
'templates' => array(':hide', 'customTpl'),
'protected' => array(':hide', 'protected'),
'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'"
);
$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 ''"
);

View File

@@ -5,7 +5,7 @@
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
<?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): ?>
<script>
<?php echo $this->map; ?>

View File

@@ -57,7 +57,20 @@ class LeafletMapElement extends \ContentElement
$GLOBALS['TL_BODY'][] = '<script>' . $map .'</script>';
$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) {
throw $e;
}