https://docs.bludit.com/en/content/custom-fields
Which shows there is a 'default' option, however for boolean operator default doesn't work be it "true", true, "1" , or 1 to have the check box enabled by default on new content creation.
Code: Select all
[
{
"name": "vgd_show_in_menu",
"type": "bool",
"label": "Show Page in Navigation",
"default": "true",
"tip": "Toggle whether this page appears in the navigation menu."
}
]Code: Select all
<?php if (!empty($site->customFields())) : ?>
<div id="nav-custom" class="tab-pane fade" role="tabpanel" aria-labelledby="custom-tab">
<?php
$customFields = $site->customFields();
foreach ($customFields as $field => $options) {
if (!isset($options['position'])) {
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'] : '')
));
} 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'] : '')
));
}
}
}
?>
</div>
<?php endif ?>
So I had to change my custom field entry to
Code: Select all
[
{
"name": "vgd_show_in_menu",
"type": "bool",
"label": "Show Page in Navigation",
"checked": true,
"tip": "Toggle whether this page appears in the navigation menu."
}
]
Came across this because I'm building my own theme to allow for some theme-based toggles or declarations on the content so that a user doesn't neccessarily have to dive into editing the theme files.
Though would be nice if either could happen (if not already possible)
- the ability to define custom fields to show up from the theme's functions.php (if it won't somehow conflict with someone already putting something into the custom fields text box in the admin panel)
- the ability to create site-wide custom fields that may either show up under "General", or "Theme Options" , so that a user may be able to change small things such as theme accent colors, layout choices, or other small tweaks.

