stagem / zfc-system-config
ZF 系统配置模块
0.0.1
2018-03-20 16:34 UTC
Requires
- php: >=5.6 || >=7.0
This package is not auto-updated.
Last update: 2024-09-23 07:27:55 UTC
README
创建此模块的灵感来自 Magento 系统配置。Magento 有一个非常好的配置结构,用于扩展配置,在大多数情况下不需要任何编程技能。
现在这个模块只提供了创建配置的最基本功能。目前许多功能还未实现。欢迎贡献。
自解释配置结构
默认情况下,ZF 使用数组配置结构。此模块以类似的方式工作。我们建议在您的模块结构下创建自定义 system.config.php
文件,并将其放置在 config/module.config.php
文件附近。
注释的行尚未实现。
// src/Your/Module/config/module.config.php return [ 'system' => require 'system.config.php', ];
// src/Your/Module/config/system.config.php return [ 'tabs' => [ 'myconf' => [ 'label' => 'My Configuration', 'sort_order' => '150', 'translate' => 'label', ], ], 'sections' => [ 'tab1' => [ 'label' => 'Tab #1', 'tab' => 'myconf', 'sort_order' => '10', #'show_in_default' => '1', #'show_in_website' => '1', #'show_in_store' => '1', #'translate' => 'label', #'module' => 'adminhtml', 'groups' => [ 'general' => [ 'label' => 'General', 'sort_order' => '50', #'comment' => 'This is a <strong>global comment</strong> about my <em>configuration</em>.<br>You can specify <u>custom html</u> tags. <a href="/">Click here for example!</a>', #'translate' => ['label', 'comment'], 'fields' => [ 'text_field' => [ 'label' => 'Text Field', 'frontend_type' => 'text', 'sort_order' => '10', #'comment' => 'Text field with store view scope.', ##'translate' => ['label', 'comment'], ], 'textarea' => [ 'label' => 'Textarea', 'frontend_type' => 'textarea', 'sort_order' => '20', #'comment' => 'Textarea with store view scope.', #'translate' => ['label', 'comment'], ], 'dropdown' => [ #'label' => 'Dropdown', #'comment' => 'Dropdown with global scope.', #'frontend_type' => 'select', #'source_model' => 'jr_customconfigexample/system_config_source_dropdown_values', #'sort_order' => '30', #'translate' => ['label', 'comment'], ], 'multiple_dropdown' => [ #'label' => 'Multiselect', #'comment' => 'Multiselect with global scope.', #'frontend_type' => 'multiselect', #'source_model' => 'jr_customconfigexample/system_config_source_dropdown_values', #'sort_order' => '40', #'translate' => ['label', 'comment'], ], 'file' => [ #'label' => 'File', #'comment' => 'File saved in <strong><span style="color: red;">var/uploads</span></strong> folder.', #'frontend_type' => 'file', #'backend_model' => 'adminhtml/system_config_backend_file', #'upload_dir' => 'var/uploads', #'sort_order' => '50', #'translate' => ['label', 'comment'], ], 'time' => [ #'label' => 'Time', #'frontend_type' => 'time', #'sort_order' => '52', #'translate' => ['label', 'comment'], ], 'active' => [ #'label' => 'Enable/Disable', #'frontend_type' => 'select', #'sort_order' => '54', #'source_model' => 'adminhtml/system_config_source_enabledisable', #'translate' => ['label', 'comment'], ], 'heading_example' => [ #'label' => 'Heading example', #'frontend_model' => 'adminhtml/system_config_form_field_heading', #'sort_order' => '55', #'translate' => ['label'], ], 'boolean' => [ #'label' => 'Boolean', #'comment' => 'Boolean with website scope and dependant fields when Yes is selected.', #'frontend_type' => 'select', #'source_model' => 'adminhtml/system_config_source_yesno', #'sort_order' => '60', #'translate' => ['label', 'comment'], ], 'dependant_text_field' => [ #'label' => 'Dependant Text Field', #'comment' => 'This field depends of boolean value above.', #'frontend_type' => 'text', #'sort_order' => '70', #'translate' => ['label', 'comment'], #'depends' => [ # 'boolean' => '1', #], ], ], ], ], ], ], ];
使用方法
您可以使用 sysConfig
视图助手来访问配置
<?= $this->sysConfig('tab1/general/text_field') ?> <?= $this->sysConfig('design/head/default_title') ?>