mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 11:26:04 +01:00
Configuration: fill up the data from system configuration if user config doesn't exist
This commit is contained in:
@@ -222,10 +222,11 @@ class Admin
|
||||
case 'configuration':
|
||||
case 'system':
|
||||
$type = 'system';
|
||||
$blueprints = $this->blueprints($type);
|
||||
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
|
||||
$obj = new Data\Data($file->content(), $blueprints);
|
||||
$blueprints = $this->blueprints("config/{$type}");
|
||||
$config = $this->grav['config'];
|
||||
$obj = new Data\Data($config->get('system'), $blueprints);
|
||||
$obj->merge($post);
|
||||
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
|
||||
$obj->file($file);
|
||||
$data[$type] = $obj;
|
||||
break;
|
||||
@@ -233,10 +234,11 @@ class Admin
|
||||
case 'settings':
|
||||
case 'site':
|
||||
$type = 'site';
|
||||
$blueprints = $this->blueprints($type);
|
||||
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
|
||||
$obj = new Data\Data($file->content(), $blueprints);
|
||||
$blueprints = $this->blueprints("config/{$type}");
|
||||
$config = $this->grav['config'];
|
||||
$obj = new Data\Data($config->get('site'), $blueprints);
|
||||
$obj->merge($post);
|
||||
$file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
|
||||
$obj->file($file);
|
||||
$data[$type] = $obj;
|
||||
break;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% include 'partials/blueprints.html.twig' with { blueprints: admin.blueprints('config/system'), data: admin.data('system') } %}
|
||||
{% set data = admin.data('system') %}
|
||||
{% include 'partials/blueprints.html.twig' with { blueprints: data.blueprints, data: data } %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{% for field in field.fields %}
|
||||
{% if field.type %}
|
||||
{% set value = data.value(field.name) %}
|
||||
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
|
||||
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<form id="blueprints" method="post">
|
||||
{% set form_id = form_id ? form_id : 'blueprints' %}
|
||||
|
||||
<form id="{{ form_id }}" method="post">
|
||||
<h1>New Page</h1>
|
||||
{% for field in blueprints.fields %}
|
||||
{% if field.type %}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<form id="blueprints" method="post">
|
||||
{% set form_id = form_id ? form_id : 'blueprints' %}
|
||||
|
||||
<form id="{{ form_id }}" method="post">
|
||||
{% for field in blueprints.fields %}
|
||||
{% if field.type %}
|
||||
{% set value = data.value(field.name) %}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<form id="blueprints" method="post">
|
||||
{% set form_id = form_id ? form_id : 'blueprints' %}
|
||||
|
||||
<form id="{{ form_id }}" method="post">
|
||||
{% for field in blueprints.fields %}
|
||||
{% if field.type %}
|
||||
{% set value = data.value(field.name) %}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% include 'partials/blueprints.html.twig' with { blueprints: admin.blueprints('config/site'), data: admin.data('site') } %}
|
||||
{% set data = admin.data('site') %}
|
||||
{% include 'partials/blueprints.html.twig' with { blueprints: data.blueprints, data: data } %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user