Custom fields with positions
This commit is contained in:
parent
23237cb05d
commit
3c72a8eafb
@ -113,18 +113,23 @@ EOF;
|
||||
}
|
||||
|
||||
$tip = '';
|
||||
if (isset($args['tip'])) {
|
||||
if (!empty($args['tip'])) {
|
||||
$tip = '<small class="form-text text-muted">'.$args['tip'].'</small>';
|
||||
}
|
||||
|
||||
$label = '';
|
||||
if (isset($args['label'])) {
|
||||
$label = '<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100" for="'.$id.'">'.$args['label'].'</label>';
|
||||
$class = 'form-group m-0';
|
||||
if (isset($args['class'])) {
|
||||
$class = $args['class'];
|
||||
}
|
||||
|
||||
$class = 'form-control';
|
||||
if (isset($args['class'])) {
|
||||
$class = $class.' '.$args['class'];
|
||||
$labelClass = 'mt-4 mb-2 pb-2 border-bottom text-uppercase w-100';
|
||||
if (isset($args['labelClass'])) {
|
||||
$labelClass = $args['labelClass'];
|
||||
}
|
||||
|
||||
$label = '';
|
||||
if (!empty($args['label'])) {
|
||||
$label = '<label class="'.$labelClass.'" for="'.$id.'">'.$args['label'].'</label>';
|
||||
}
|
||||
|
||||
$type = 'text';
|
||||
@ -133,9 +138,9 @@ EOF;
|
||||
}
|
||||
|
||||
return <<<EOF
|
||||
<div class="form-group m-0">
|
||||
<div class="$class">
|
||||
$label
|
||||
<input type="text" value="$value" class="$class" id="$id" name="$name" placeholder="$placeholder" $disabled>
|
||||
<input type="text" value="$value" class="form-control" id="$id" name="$name" placeholder="$placeholder" $disabled>
|
||||
$tip
|
||||
</div>
|
||||
EOF;
|
||||
@ -275,7 +280,12 @@ EOF;
|
||||
|
||||
$class = 'form-group m-0';
|
||||
if (isset($args['class'])) {
|
||||
$class = $class.' '.$args['class'];
|
||||
$class = $args['class'];
|
||||
}
|
||||
|
||||
$labelClass = 'mt-4 mb-2 pb-2 border-bottom text-uppercase w-100';
|
||||
if (isset($args['labelClass'])) {
|
||||
$labelClass = $args['labelClass'];
|
||||
}
|
||||
|
||||
$type = 'text';
|
||||
@ -285,7 +295,7 @@ EOF;
|
||||
|
||||
$label = '';
|
||||
if (!empty($args['label'])) {
|
||||
$label = '<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100">'.$args['label'].'</label>';
|
||||
$label = '<label class="'.$labelClass.'">'.$args['label'].'</label>';
|
||||
}
|
||||
|
||||
$checked = $args['checked']?'checked':'';
|
||||
|
@ -53,7 +53,7 @@ echo Bootstrap::formOpen(array(
|
||||
?>
|
||||
|
||||
<!-- TOOLBAR -->
|
||||
<div id="jseditorToolbar">
|
||||
<div id="jseditorToolbar" class="mb-1">
|
||||
<div id="jseditorToolbarRight" class="btn-group btn-group-sm float-right" role="group" aria-label="Toolbar right">
|
||||
<button type="button" class="btn btn-light" id="jsmediaManagerOpenModal" data-toggle="modal" data-target="#jsmediaManagerModal"><span class="fa fa-image"></span> <?php $L->p('Images') ?></button>
|
||||
<button type="button" class="btn btn-light" id="jsoptionsSidebar" style="z-index:30"><span class="fa fa-cog"></span> <?php $L->p('Options') ?></button>
|
||||
@ -293,6 +293,7 @@ echo Bootstrap::formOpen(array(
|
||||
<?php
|
||||
$customFields = $site->customFields();
|
||||
foreach ($customFields as $field=>$options) {
|
||||
if ( !isset($options['position']) ) {
|
||||
if ($options['type']=="string") {
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
@ -312,6 +313,7 @@ echo Bootstrap::formOpen(array(
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@ -361,14 +363,76 @@ echo Bootstrap::formOpen(array(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Custom fields: TOP -->
|
||||
<?php
|
||||
$customFields = $site->customFields();
|
||||
foreach ($customFields as $field=>$options) {
|
||||
if ( isset($options['position']) && ($options['position']=='top') ) {
|
||||
if ($options['type']=="string") {
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'value'=>$page->custom($field),
|
||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'class'=>'mb-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
|
||||
));
|
||||
} elseif ($options['type']=="bool") {
|
||||
echo Bootstrap::formCheckbox(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'checked'=>$page->custom($field),
|
||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'class'=>'mb-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
<div class="form-group mt-1 mb-1">
|
||||
<div class="form-group mb-1">
|
||||
<input id="jstitle" name="title" type="text" class="form-control form-control-lg rounded-0" value="<?php echo $page->title() ?>" placeholder="<?php $L->p('Enter title') ?>">
|
||||
</div>
|
||||
|
||||
<!-- Editor -->
|
||||
<textarea id="jseditor" class="editable h-100" style=""><?php echo $page->contentRaw(true) ?></textarea>
|
||||
|
||||
<!-- Custom fields: BOTTOM -->
|
||||
<?php
|
||||
$customFields = $site->customFields();
|
||||
foreach ($customFields as $field=>$options) {
|
||||
if ( isset($options['position']) && ($options['position']=='bottom') ) {
|
||||
if ($options['type']=="string") {
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'value'=>$page->custom($field),
|
||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'class'=>'mt-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
|
||||
));
|
||||
} elseif ($options['type']=="bool") {
|
||||
echo Bootstrap::formCheckbox(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'checked'=>$page->custom($field),
|
||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'class'=>'mt-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- Modal for Delete page -->
|
||||
|
@ -47,7 +47,7 @@ echo Bootstrap::formOpen(array(
|
||||
?>
|
||||
|
||||
<!-- TOOLBAR -->
|
||||
<div id="jseditorToolbar">
|
||||
<div id="jseditorToolbar" class="mb-1">
|
||||
<div id="jseditorToolbarRight" class="btn-group btn-group-sm float-right" role="group" aria-label="Toolbar right">
|
||||
<button type="button" class="btn btn-light" id="jsmediaManagerOpenModal" data-toggle="modal" data-target="#jsmediaManagerModal"><span class="fa fa-image"></span> <?php $L->p('Images') ?></button>
|
||||
<button type="button" class="btn btn-light" id="jsoptionsSidebar" style="z-index:30"><span class="fa fa-cog"></span> <?php $L->p('Options') ?></button>
|
||||
@ -268,6 +268,7 @@ echo Bootstrap::formOpen(array(
|
||||
<?php
|
||||
$customFields = $site->customFields();
|
||||
foreach ($customFields as $field=>$options) {
|
||||
if ( !isset($options['position']) ) {
|
||||
if ($options['type']=="string") {
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
@ -286,6 +287,7 @@ echo Bootstrap::formOpen(array(
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@ -333,14 +335,76 @@ echo Bootstrap::formOpen(array(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Custom fields: TOP -->
|
||||
<?php
|
||||
$customFields = $site->customFields();
|
||||
foreach ($customFields as $field=>$options) {
|
||||
if ( isset($options['position']) && ($options['position']=='top') ) {
|
||||
if ($options['type']=="string") {
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'value'=>(isset($options['default'])?$options['default']:''),
|
||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'class'=>'mb-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
|
||||
));
|
||||
} elseif ($options['type']=="bool") {
|
||||
echo Bootstrap::formCheckbox(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'checked'=>(isset($options['checked'])?true:false),
|
||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'class'=>'mb-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
<div id="jseditorTitle" class="form-group mt-1 mb-1">
|
||||
<div id="jseditorTitle" class="form-group mb-1">
|
||||
<input id="jstitle" name="title" type="text" class="form-control form-control-lg rounded-0" value="" placeholder="<?php $L->p('Enter title') ?>">
|
||||
</div>
|
||||
|
||||
<!-- Editor -->
|
||||
<textarea id="jseditor" class="editable h-100 mb-1"></textarea>
|
||||
|
||||
<!-- Custom fields: BOTTOM -->
|
||||
<?php
|
||||
$customFields = $site->customFields();
|
||||
foreach ($customFields as $field=>$options) {
|
||||
if ( isset($options['position']) && ($options['position']=='bottom') ) {
|
||||
if ($options['type']=="string") {
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'value'=>(isset($options['default'])?$options['default']:''),
|
||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'class'=>'mt-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
|
||||
));
|
||||
} elseif ($options['type']=="bool") {
|
||||
echo Bootstrap::formCheckbox(array(
|
||||
'name'=>'custom['.$field.']',
|
||||
'label'=>(isset($options['label'])?$options['label']:''),
|
||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
||||
'checked'=>(isset($options['checked'])?true:false),
|
||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
|
||||
'class'=>'mt-2',
|
||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- Modal for Media Manager -->
|
||||
|
Loading…
Reference in New Issue
Block a user