nf/input

NF主题的输入包

1.0.3 2019-11-02 03:44 UTC

This package is auto-updated.

Last update: 2024-08-29 05:23:14 UTC


README

它是我们主题https://github.com/hieu-pv/nf-theme的一个扩展工具包

安装

克隆仓库

git clone https://github.com/hieu-pv/nf-extension-kit.git 

更新您的信息

如果您想在WordPress启动时提供一些功能,我们将它们注册在src/ExtensionKitServiceProvider.php

例如:注册CSS/JS文件

然后在主题的config/app.php中注册服务提供者

  'providers'  => [
        // .... Others providers 
        \NightFury\ExtensionKit\ExtensionKitServiceProvider::class,
    ],

编译资源文件

{提示}您可以在/assets/scripts/app.js中编写自己的JavaScript,并在/assets/styles/app.scss中编写CSS

所有编译文件都将位于/assets/dist

安装node模块
npm install
运行资源编译器
npm run build
以生产模式运行资源编译器
npm run prod
监视文件更改并编译
npm run watch

{提示}您可以在webpack.config.js中编写自己的配置

服务

Blade是这个工具包提供的简单但强大的模板引擎。您可以通过NightFury\ExtensionKit\Facades\View使用它

{提示}Blade文件位于/resources/views

例如,我们有一个文件/resources/views/example.blade.php,然后我们可以使用以下代码使用此文件

echo NightFury\ExtensionKit\Facades\View::render('example', ['data' => 'some test data here']);

有关Blade引擎的更多信息,请参阅https://laravel.net.cn/docs/5.5/blade

与本地仓库一起工作

除了工件仓库外,您还可以使用路径仓库,这允许您依赖于本地目录,无论是绝对路径还是相对路径。这对于处理单体仓库特别有用。

要将本地仓库添加到您的项目,请将以下代码添加到您的composer.json中,然后运行命令composer install

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }
}

例如

    {
        "require": {
            "nf/extension-kit": "dev-master"
        },
        "repositories": [{
            "type": "path",
            "url": "../../../../nf-extension-kit" // use relative path here
        }]
    }

有关更多信息,请参阅https://getcomposer.org/doc/05-repositories.md

扩展配置

在某些情况下,我们需要从用户那里获取一些配置,我们可以使用nf/theme-option

检查包仓库以安装和支持的字段https://github.com/hieu-pv/nf-theme-option

在您的服务提供者src/ExtensionKitServiceProvider.php中注册选项方案
use use NightFury\Option\Abstracts\Input;

\NightFury\Option\Facades\ThemeOptionManager::add([
    'name'   => 'Exetension Kit',
    'fields' => [
        [
            'label'    => 'Text',
            'name'     => 'theme_option_text',
            'type'     => Input::TEXT,
            'required' => true,
        ],
        [
            'label'    => 'Textarea',
            'name'     => 'theme_option_textarea',
            'type'     => Input::TEXTAREA,
            'required' => true,
        ],
        [
            'label'    => 'Email',
            'name'     => 'theme_option_email',
            'type'     => Input::EMAIL,
            'required' => true,
        ],
        [
            'label'       => 'Gallery',
            'name'        => 'theme_option_gallery',
            'type'        => Input::GALLERY,
            'description' => 'We can select multi file. Drag and Drop to re-order content',
        ],
        [
            'label'       => 'Gallery With Meta Field',
            'name'        => 'theme_option_gallery_with_meta',
            'type'        => Input::GALLERY,
            'description' => 'Gallery with meta field, for now we support text and textarea on meta field.',
            'meta'        => [
                [
                    'label' => 'Text',
                    'name'  => 'meta_text',
                    'type'  => Input::TEXT,
                ],
                [
                    'label' => 'Textarea',
                    'name'  => 'meta_textarea',
                    'type'  => Input::TEXTAREA,
                ],
            ],
        ], [
            'label'       => 'Image',
            'name'        => 'theme_option_image',
            'type'        => Input::IMAGE,
            'description' => 'Choose your image by clicking the button bellow',
        ],
        [
            'label'   => 'Select',
            'name'    => 'theme_option_select',
            'type'    => Input::SELECT,
            'options' => [
                [
                    'value'    => 'first',
                    'label'    => 'First Value',
                    'selected' => true,
                ],
                [
                    'value'    => 'second',
                    'label'    => 'Second Value',
                    'selected' => false,
                ],
            ],
        ],
    ],
]);