despark / html-template-curator
Laravel 5.1 包,使您能够管理复杂的HTML模板,保持设计完整性。
Requires
- php: >=5.5.9
- cviebrock/image-validator: 2.0.*@beta
- illuminate/database: 5.1.*
- illuminate/routing: 5.1.*
- illuminate/support: 5.1.*
- intervention/image: ~2
- intervention/imagecache: ~2.1
- laravelcollective/html: ~5.0
README
Laravel 5 包,使您能够管理复杂的HTML模板,保持设计完整性。(如果您想使用此插件与 Laravel 4 配合,请需要 v1.0.2 )
此包的目的是帮助您实现复杂HTML视图的富文本编辑,但去除破坏您才华横溢的设计师所创作的美丽设计的风险。理念是,当编写HTML模板时,您会给所有想要通过HTML模板管理器启用编辑的元素添加 eg-editable
类,而管理器会自动在初始化时仅为其注入内联编辑器。
开始使用
-
将以下依赖项添加到 composer.json 的 require 部分
"despark/html-template-curator": "2.*"
为了使用此插件,您需要将 composer 的
minimum-stability
设置为 beta,因为我们正在使用 cviebrock/image-validator 的 beta 版本,因为 Laravel 5 的稳定版本尚未提供。 -
运行 composer update
-
在 * config/app.php* 中添加 HTML 模板管理器的服务提供者
'Despark\HtmlTemplateCurator\HtmlTemplateCuratorServiceProvider::class',
-
运行
php artisan vendor:publish --provider="Despark\HtmlTemplateCurator\HtmlTemplateCuratorServiceProvider" --tag="views"
以发布视图 -
运行
php artisan vendor:publish --provider="Despark\HtmlTemplateCurator\HtmlTemplateCuratorServiceProvider" --tag="config"
以发布配置文件 -
运行
php artisan vendor:publish --provider="Despark\HtmlTemplateCurator\HtmlTemplateCuratorServiceProvider" --tag="public"
以发布资产 -
将您的出色HTML模板(包括所有可编辑部分上所需的
eg-editable
)放入您公共目录中的一个名为 templates 的新文件夹中。(在 /public/packages/despark/html-template-curator/templates/ 文件夹中,您可以找到一些HTML模板的示例) -
在您想要启用模板管理器功能的视图中,您至少需要以下两个元素。
一个
<select>
字段,它将加载可用的模板,以便用户可以选择要编辑的布局。例如:{{ Form::select('template', [], null, ['class' => 'form-control js-artice-template']) }}
一个
<textarea>
元素,其中将加载模板的原始和最新HTML。(请注意,此元素将由脚本自动隐藏)例如:{{ Form::textarea('content', null, ['id' => 'content']) }}
-
在上述元素定义之后将编辑器包含的视图中,添加以下代码
@include('packages.despark.html-template-curator.partials.modal_editor_definition') {{-- Includes the modal popup --}} @include('packages.despark.html-template-curator.partials.script') {{-- The needed JavaScript files for the HTML Template Curator --}} <script> $(function () { $('.js-artice-template').templateEditor('#content'); /* In addition you can define the currently selected template with its value in select box as second parameter - usefull when editing already saved page. And custom selector for the container, which will contain the visual presentation of the template as a 3rd parameter E.g. $('.js-artice-template').templateEditor('#content', 'book', '#my_selector');*/ }); </script>
如果您已经在代码中其他地方需要了jQuery,可以取消注释 {{-- <script src="{{ asset('vendor/html-template-curator/js/vendor/jquery/dist/jquery.min.js') }}"></script> --}}
。 10. 在以下配置中添加可用的模板:* config/html-template-curator.php* 中的配置数组下的 templates
键。将数组的每个元素的键设置为存储模板的文件夹名称,并将其值设置为在 select 字段中显示的显示名称。 11. 确保您已在 * config/app.php* 文件中设置了正确的应用URL。 12. 完成后,导航到您创建的页面并开始编辑模板。
在包视图中,您将找到一个名为 examples 的文件夹,其中包含编辑器的示例实现。
备注:请注意,这仍然是进行中的工作,所以可能还有一些小问题需要解决,但我相信您和您出色的拉取请求将使它成为一个出色的插件。