定制 shomeya/shomeya_utility 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

shomeya/shomeya_utility

Composer 安装命令:

composer require shomeya/shomeya_utility

包简介

Shomeya utility tools for Drupal

README 文档

README

This module provides several useful features, such as an environment indicator, a style guide, some render elements and template functions/helpers.

Build metadata

This module provide a helper class to access information about the build, such as latest Git commit, date, time, as well as who and where the build was packaged. This information is available in the status report at admin/reports/status. It also includes links to Github for relevant commits as long as the Github URL is set in settings.php:

$config['shomeya_utility.settings']['github_url'] = 'https://github.com/shomeya/projectname';

Environment indicator

An environment indicator is available that provides text and an icon indicating which environment you are viewing:

environment indicator for production with green checkmark

This functionality is based on the enviroment specified in the settings.json file and is mapped in src/Environment.php.

Style Guide

This module provides a sample style guide at styleguide/web with additional pages for form elements and Drupal elements at styleguide/web/drupal/form and styleguide/web/drupal/elements.

Elements

A time element is defined in src/Element/Time.php. This element also supports optionally rendering as a dynamic 'time ago' with Javascript if the option is enabled.

$build = [
  '#type' => 'time',
  '#timestamp' => '1456527560', // Unix timestamp to use for the date, will be used to populate a ISO 8601 in the 'datetime' attribute of the tag
  '#value' => 'Friday, Feb. 26th', // The value to be displayed
  '#options' => [
    'timeago' => TRUE, // Whether or not the element should be rendered as timeago using javascript
  ],
  '#attributes' => [ // additional attributes for the element
  	'class' => 'my-time-element', 
  ],
];

Template functions/helpers

There are several helper function that are exposed to Twig templates:

URL from URI

This helper turns a Drupal URI (such as internal:/about-us , entity:node/1234, or base:robots.txt) into a fully qualified URL:

<a href="{{ url_from_uri(node.field_link.uri) }}">My Link</a>

It supports options that will be based to Url::fromUri() such as query, absolute, https, and more:

<a href="{{ url_from_uri(node.field_link.uri, {absolute: true}) }}">My Link</a>

Time

Supports creation of a time element from a timestamp:

{# Without value provided a value will be formatted from the timestamp #}
{{ time(item.timestamp) }}

It supports an optional value to be displayed if you wish to customize the date display:

{{ time(item.timestamp, item.date) }}

Finally it supports all options that can be passed to the time element, and additional options for generating a value if one is not provided:

{# Type and format correspond to options passed to DateFormatter::format() #}
{{ time(item.timestamp, null, {type: custom, format: 'F j Y'}) }}

The last example will output something like:

<time datetime="2016-02-26T14:59:20-08:00">February 26 2016</time>

Time ago

Support time element from timestamp with timeago set to true:

{{ time_ago(item.timestamp) }}

The output will be:

<time datetime="2016-02-26T14:59:20-08:00" data-drupal-time-ago>Fri, 02/26/2016 - 14:59</time>

This also automatically includes jquery.timeago.js which will format the value as a time ago, such as 'less than a minute ago.'

This support the same options for value and options as the time helper.

Time From String

This function supports generating a time element from a date string parsed with strtotime():

{{ time_from_string('Fri, 02/26/2016 - 14:59') }}

Also allows for value, options.

Time ago from string

Supports generating a time ago tag from a string:

{{ time_ago_from_string('Fri, 02/26/2016 - 14:59') }}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL
  • 更新时间: 2017-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固