承接 newism/craft3-fields 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

newism/craft3-fields

最新稳定版本:2.1.0

Composer 安装命令:

composer require newism/craft3-fields

包简介

Address, telephone and email fields for CraftCMS

README 文档

README

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:

$ composer require newism/craft-fields && ./craft plugin/install nsm-fields

Configuration

  • If you're using Address Autocomplete you'll need an api key.
  • If you're embedding Instagram you'll need an api key.
  • If you're embedding Facebook you'll need an api key.

Add the api keys to your environment and set in the plugin settings. See: https://craftcms.com/docs/3.x/config/#environmental-configuration

Alternatively…

Copy src/config.php to CRAFT_CONFIG_PATH and rename the file to nsm-fields.php.

Fields

Address

Address field powered by Google's dataset (commerceguys/addressing).

Features:

  • Auto-complete powered by Google Place API
  • Map powered by Google Maps Javascript API and Google Maps Geocoding API
  • Address form formatting based on country powered by commerceguys/addressing
  • Validation / Geo-coding on submission (TODO)

Template Tags:

The normalizeValue method always returns an AddressModel. All public properties are available:

Given entry.address is your field…

See: https://github.com/commerceguys/addressing/blob/master/src/AddressInterface.php
{{ entry.address.countryCode }}
{{ entry.address.administrativeArea }}
{{ entry.address.locality }}
{{ entry.address.dependentLocality }}
{{ entry.address.postalCode }}
{{ entry.address.sortingCode }}
{{ entry.address.addressLine1 }}
{{ entry.address.addressLine2 }}
{{ entry.address.organization }}
{{ entry.address.recipient }}
{{ entry.address.locale }}

See: https://github.com/commerceguys/addressing/blob/master/src/Country/Country.php
{{ entry.address.country.countryCode }}
{{ entry.address.country.name }}
{{ entry.address.country.threeLetterCode }}
{{ entry.address.country.numericCode }}
{{ entry.address.country.currencyCode }}
{{ entry.address.country.locale }}

{{ entry.address.placeData }}
{{ entry.address.latitude }}
{{ entry.address.longitude }}
{{ entry.address.mapUrl }}

Address Demo

Telephone

Telephone field powered by Googles phone number library implemented via giggsey/libphonenumber-for-php

Features:

  • Validate phone number based on country code
  • Format phone number as E164, international, national or RFC3966
  • Stores Telephone model and raw user input

Template Tags:

Given entry.telephone is your field…

{{ entry.telephone }} outputs the phone number in international format.

You can also choose a specific format:

{{ entry.telephone.format('E164') }}
{{ entry.telephone.format('international') }}
{{ entry.telephone.format('national') }}
{{ entry.telephone.format('RFC3966') }}

The raw input from the user is also available:

{{ entry.telephone.rawInput }}

Telephone Demo

Email

Features:

  • Email validation using Yii validation

Email Demo

Embed

Features:

  • Embed social media posts / media directly from a URL
  • Live preview

Template Tags:

Given entry.embedField is your field…

  • {{ entry.embedField.embedData }} outputs the returned embed object.
  • {{ entry.embedField.embedData.code | raw }} outputs the returned embed javascript code.

Additional data:

{{ entry.embedField.embedData.authorName }} // The resource author
{{ entry.embedField.embedData.authorUrl }} // The author url
{{ entry.embedField.embedData.cms }} // The cms used
{{ entry.embedField.embedData.code.html }} // The code to embed the image, video, etc
{{ entry.embedField.embedData.code.width }} // The exact width of the embed code (if exists)
{{ entry.embedField.embedData.code.height }} // The exact height of the embed code (if exists)
{{ entry.embedField.embedData.code.aspectRatio }} // The aspect ratio (width/height)
{{ entry.embedField.embedData.description }} //The page description
{{ entry.embedField.embedData.favicon }} // The favicon of the site (an .ico file or a png with up to 32x32px)
{{ entry.embedField.embedData.feeds }} // The RSS/Atom feeds
{{ entry.embedField.embedData.icon }} // The big icon of the site
{{ entry.embedField.embedData.image }} // The thumbnail or main image
{{ entry.embedField.embedData.keywords }} // The page keywords
{{ entry.embedField.embedData.language }} // The language of the page
{{ entry.embedField.embedData.languages }} // The alternative languages
{{ entry.embedField.embedData.license }} // The license url of the resource
{{ entry.embedField.embedData.providerName }} // The provider name of the page (Youtube, Twitter, Instagram, etc)
{{ entry.embedField.embedData.providerUrl }} // The provider url
{{ entry.embedField.embedData.publishedTime }} // The published time of the resource
{{ entry.embedField.embedData.redirect }}
{{ entry.embedField.embedData.title }} //The page title
{{ entry.embedField.embedData.url }} //The canonical url
{{ entry.embedField.embedData.ombed }} // oembed data 
{{ entry.embedField.embedData.linkedData }} // json-LD data

Note: embed data saved with v1 saved the html to {{entry.embedField.embedData.code}}. In v2 {{ entry.embedField.embedData.code }} changed to an array. Your templates will need to account for both versions… something like:

{{ (entry.embedField.embedData.code.html|default ?: entry.embedField.embedData.code|default) | raw }}

Embed Demo

Person Name

Person name field with:

  • Honorific Prefix
  • Given Names
  • Additional Names
  • Family Names
  • Honorific Suffix

Person Name Demo

Gender

Non-binary gender field with:

  • Sex
  • Identity

Gender

Road Map

Some things to do, and ideas for potential features:

  • Split out each field into it's own plugin. Keep this plugin as a single composer file which pulls all fields in
  • Address validation / Geo-coding on submission
  • Display address as text in field with option to "Edit" to reduce size of field in UI
  • Update commerceguys/addressing when next stable version is released

Credits

Brought to you by Newism

newism/craft3-fields 适用场景与选型建议

newism/craft3-fields 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33.71k 次下载、GitHub Stars 达 54, 最近一次更新时间为 2017 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「Craft」 「craftcms」 「craft-plugin」 「nsm-fields」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 newism/craft3-fields 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 newism/craft3-fields 我们能提供哪些服务?
定制开发 / 二次开发

基于 newism/craft3-fields 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 54
  • Watchers: 3
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-04