alaame/voyager-themes

此软件包最新版本(0.0.1)没有提供许可信息。

此钩子将添加对Voyager前端主题的支持

0.0.1 2020-06-09 13:54 UTC

This package is auto-updated.

Last update: 2024-09-09 23:45:35 UTC


README

Voyager 主题

这是一个用于Voyager和钩子系统的主题钩子

Voyager Themes Admin Page

安装钩子

您可以使用以下Artisan命令安装此钩子

php artisan hook:install voyager-themes

添加主题

voyager-themes 钩子将在 resources/themes 文件夹内查找任何包含同名 .json 文件的文件夹。 (您可以在配置中更改主题文件夹的位置)

例如,如果您有一个名为 sample-theme 的文件夹,在该文件夹内还有一个名为 sample-theme.json 的文件,其内容如下

{
    "name": "Sample Theme",
    "version": "1.0"
}

Voyager 主题将检测到这是一个新的主题。您还可以包含主题的示例截图,这将是 sample-theme.jpg (800x500像素)以获得最佳效果

实际上,您可以在以下位置查看 sample-theme 仓库: https://github.com/thedevdojo/sample-theme

您可以在Voyager中激活此主题,然后当您想告诉应用程序加载哪个视图时,可以使用

return view('theme::welcome')

这将然后在当前活动主题文件夹中查找名为 welcome.blade.php 的新视图 :D

主题配置

您可以通过运行以下命令将配置发布到项目中

php artisan vendor:publish

您需要发布 voyager-themes-config,现在您将在 config/themes.php 中看到一个新配置,如下所示

<?php

return [

    'themes_folder' => resource_path('views/themes'),
    'publish_assets' => true

];

现在,您可以选择将主题文件夹放置在另一个位置。默认情况下,它将被放入 resources/views 文件夹;然而,您可以将其更改为任何您想要的地点。

此外,您可以设置 publish_assetstruefalse,如果设置为 true,则每次扫描主题目录时,都会将主题中的 assets 文件夹发布到名为 themes 的新公共文件夹中。将其设置为 false,则不会发生此操作。

主题选项

您还可以通过在主题文件夹中包含另一个名为 options.blade.php 的文件,轻松添加一些选项

Voyager Theme Options Page

options.blade.php 文件中,您现在可以添加一个新字段,就像这样简单

{!! theme_field('text', 'title') !!}

这将添加一个新的 文本字段,并使用 title 存储它。因此,现在如果您想在主题文件中的任何地方引用此值,您只需简单地像这样输出它

{{ theme('title') }}

不是很简单吗!

请查看以下对 theme_field 函数的所有以下解释。

theme_field() 函数

theme_field() 函数可以用来在我们的主题选项页面显示字段。请查看以下函数的定义、示例、说明和字段类型

定义

theme_field(
    $type, 
    $key,
    $title = '',
    $content = '', 
    $details = '', 
    $placeholder = '', 
    $required = 1)

示例:请求标题的文本框

{!! theme_field(
        'text', 
        'headline', 
        'My Aweseome Headline', 
        '{}', 
        'Add your Headline here', 
        0) 
 !!}

只有前两个参数是必需的

{!! theme_field('text', 'headline') !!}

说明

$type
    This is the type of field you want to display, you can
    take a look at all the fields from the TYPES OF FIELDS
    section below.
 $key
    This is the key you want to create to reference the
    field in your theme.
 $title
    This is the title or the label above the field
  $content 
    The current contents or value of the field, if the field
    has already been created in the db, the value in the
    database will be used instead
  $details
    The details of the field in JSON. You can find more 
    info about the details from the following URL:
    https://voyager.readme.io/docs/additional-field-options
  $placeholder
    The placeholder value of the field
  $required
    Whether or not this field is required

字段类型

checkbox, color, date, file, image, multiple_images,
number, password, radio_btn, rich_text_box, code_editor,
markdown_editor, select_dropdown, select_multiple, text,
text_area, timestamp, hidden, coordinates