ludmanp/typicms-pageoptions 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ludmanp/typicms-pageoptions

最新稳定版本:14.0.0

Composer 安装命令:

composer require ludmanp/typicms-pageoptions

包简介

Allow to add more parameters to a Page in TypiCMS

README 文档

README

Latest Version on Packagist Total Downloads MIT Licence

Allow to extend TypiCMS Page properties according to page templates.

Installation

You can install the package via composer:

composer require ludmanp/typicms-pageoptions

To prepare for usage you can run

php artisan page-options:install

The command will publish and run the migrations.

You can alternatively run separate commands to do these operations:

php artisan vendor:publish --tag="page-options-migrations"
php artisan migrate

Optionally, you can publish the views using

php artisan vendor:publish --tag="typicms-pageoptions-views"

Usage

Admin

Include

<x-pageoptions-admin-form :model="$model" />

into resources/viwes/vendor/pages/admin/_from.blade.php.

$model is the current Page model

Create blade file in resources/viwes/vendor/page-options/admin directory with page tempalate name. For example default.blade.php

To add options you can use, for example,

{!! BootForm::text(__('Description'), 'options[description]') !!}
{!! TranslatableBootForm::text(__('Phone number'), 'options[phone][number]') !!}

To include specific images, use

<x-pageoptions-image :model="$model" name="preview_image_id" label="Preview image"/>
<x-pageoptions-image :model="$model" name="phone.icon_id" label="Phone icon"/>

name is option's name, use dots to make multilevel array. label is optional, but recommended to distinguish from other image fields

The same way you can add file fields

<x-pageoptions-file :model="$model" name="specification" label="Specification"/>

Public

To output PageOptions use in page template (pages/public/*.blade/php)

To output simple option use

{{ $pageOptions->present()->option('phone') }}

To output translatable option use

{{ $pageOptions->present()->optionTranslated('company.name') }}

There is available optional locale parameter

{{ $pageOptions->present()->optionTranslated('company.name', 'en') }}

To output image use

<img src="{{ $pageOptions->present()->optionsImage('contact.image') }}"
    alt="{{ optional($pageOptions->present()->optionsFile('contact.image'))->alt_attribute ?? 'Contacts' }}"/>

Additional parameters width, height and options are available, like in presenter's image method.

To get file model use.

$pageOptions->present()->optionsFile('contact.file')

As you can see above it is available also for images to get alt_attribute for example.

To make link to file you can write like following

<a href="{{ optional($pageOptions->present()->optionsFile('contact.file'))->url }}">File</a>

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固