summaryrefslogtreecommitdiff
path: root/views/mods/mod_productvars/renderTemplate.phtml
blob: ba8cf5815c4fd7fb8e2f75c2616af2e655dec407 (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
<?php

	/**
	 * Template für die Integration der Produktvariablen in das Template
	 *
	 * Die Beschriftung steht über dem Feld, Checkboxen stehen mit ihrem Text in einer Zeile.
	 * Pflichtfelder tragen required, der leere Platzhalter der Auswahl wird serverseitig zu not_set.
	 * Die Klassen wpsg_mod_productvars_row, _label und _input bleiben für bestehende Anpassungen im Theme erhalten.
	 */

	$template_index = intval($this->view['wpsg_mod_productvars']['template_index']??0);

?>
<div class="wpsg_mod_productvars">
	<?php foreach ($this->view['wpsg_mod_productvars']['data'] as $pv) { ?>
	<?php

		$field_name = 'wpsg_mod_productvars['.$pv['id'].']';
		$field_id = 'wpsg_mod_productvars_'.$template_index.'_'.$pv['id'];
		$value = wpsg_getStr($pv['value']);
		$bRequired = ($pv['pflicht'] == '1');
		$strRequired = (($bRequired)?'<span class="wpsg_required" aria-hidden="true">*</span>':'');

	?>
	<div class="wpsg_mod_productvars_row wpsg_mod_productvars_typ<?php echo intval($pv['typ']); ?>">

		<?php if ($pv['typ'] == '3') { // Checkbox ?>
		<label class="wpsg_mod_productvars_check">
			<input type="hidden" value="0" name="<?php echo esc_attr($field_name); ?>" />
			<input <?php echo (($value === '1')?'checked="checked"':''); ?> type="checkbox" value="1" name="<?php echo esc_attr($field_name); ?>"<?php echo (($bRequired)?' required':''); ?> />
			<span><?php echo wpsg_hspc(__($pv['name'], 'wpsg')); ?><?php echo $strRequired; ?></span>
		</label>
		<?php } else { ?>
		<label class="wpsg_mod_productvars_label" for="<?php echo esc_attr($field_id); ?>"><?php echo wpsg_hspc(__($pv['name'], 'wpsg')); ?><?php echo $strRequired; ?></label>

		<?php if ($pv['typ'] == '1') { // Auswahlfeld ?>
		<select class="wpsg_mod_productvars_input" id="<?php echo esc_attr($field_id); ?>" name="<?php echo esc_attr($field_name); ?>"<?php echo (($bRequired)?' required':''); ?>>
			<option value=""><?php echo __('Bitte wählen', 'wpsg'); ?></option>
			<?php foreach ((array)$pv['auswahl'] as $option) { ?>
			<option <?php echo (($value === wpsg_hspc($option))?'selected="selected"':''); ?> value="<?php echo wpsg_hspc($option); ?>"><?php echo wpsg_hspc($option); ?></option>
			<?php } ?>
		</select>
		<?php } else if ($pv['typ'] == '4') { // Mehrzeiliges Textfeld ?>
		<textarea class="wpsg_mod_productvars_input" id="<?php echo esc_attr($field_id); ?>" rows="3" name="<?php echo esc_attr($field_name); ?>"<?php echo (($bRequired)?' required':''); ?>><?php echo wpsg_hspc($value); ?></textarea>
		<?php } else { // Textfeld ?>
		<input class="wpsg_mod_productvars_input" type="text" id="<?php echo esc_attr($field_id); ?>" name="<?php echo esc_attr($field_name); ?>" value="<?php echo wpsg_hspc($value); ?>"<?php echo (($bRequired)?' required':''); ?> />
		<?php } ?>
		<?php } ?>

	</div>
	<?php } ?>
</div>