mirror of
				https://github.com/getgrav/grav-plugin-admin.git
				synced 2025-11-03 20:05:53 +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 'configuration':
 | 
				
			||||||
            case 'system':
 | 
					            case 'system':
 | 
				
			||||||
                $type = 'system';
 | 
					                $type = 'system';
 | 
				
			||||||
                $blueprints = $this->blueprints($type);
 | 
					                $blueprints = $this->blueprints("config/{$type}");
 | 
				
			||||||
                $file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
 | 
					                $config = $this->grav['config'];
 | 
				
			||||||
                $obj = new Data\Data($file->content(), $blueprints);
 | 
					                $obj = new Data\Data($config->get('system'), $blueprints);
 | 
				
			||||||
                $obj->merge($post);
 | 
					                $obj->merge($post);
 | 
				
			||||||
 | 
					                $file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
 | 
				
			||||||
                $obj->file($file);
 | 
					                $obj->file($file);
 | 
				
			||||||
                $data[$type] = $obj;
 | 
					                $data[$type] = $obj;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
@@ -233,10 +234,11 @@ class Admin
 | 
				
			|||||||
            case 'settings':
 | 
					            case 'settings':
 | 
				
			||||||
            case 'site':
 | 
					            case 'site':
 | 
				
			||||||
                $type = 'site';
 | 
					                $type = 'site';
 | 
				
			||||||
                $blueprints = $this->blueprints($type);
 | 
					                $blueprints = $this->blueprints("config/{$type}");
 | 
				
			||||||
                $file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
 | 
					                $config = $this->grav['config'];
 | 
				
			||||||
                $obj = new Data\Data($file->content(), $blueprints);
 | 
					                $obj = new Data\Data($config->get('site'), $blueprints);
 | 
				
			||||||
                $obj->merge($post);
 | 
					                $obj->merge($post);
 | 
				
			||||||
 | 
					                $file = YamlFile::instance(USER_DIR . "config/{$type}.yaml");
 | 
				
			||||||
                $obj->file($file);
 | 
					                $obj->file($file);
 | 
				
			||||||
                $data[$type] = $obj;
 | 
					                $data[$type] = $obj;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@
 | 
				
			|||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% block content %}
 | 
					{% 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 %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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>
 | 
					    <h1>New Page</h1>
 | 
				
			||||||
    {% for field in blueprints.fields %}
 | 
					    {% for field in blueprints.fields %}
 | 
				
			||||||
        {% if field.type %}
 | 
					        {% 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 %}
 | 
					    {% for field in blueprints.fields %}
 | 
				
			||||||
        {% if field.type %}
 | 
					        {% if field.type %}
 | 
				
			||||||
            {% set value = data.value(field.name) %}
 | 
					            {% 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 %}
 | 
					    {% for field in blueprints.fields %}
 | 
				
			||||||
        {% if field.type %}
 | 
					        {% if field.type %}
 | 
				
			||||||
            {% set value = data.value(field.name) %}
 | 
					            {% set value = data.value(field.name) %}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@
 | 
				
			|||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% block content %}
 | 
					{% 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 %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user