Drupal 整站迁移

drush si
drush -y entity:delete shortcut_set
drush en module_name
drush then theme_name
drush cget system.site
drush ci

2022年03月06日
1 min

VIM:power of g

delete all line match pattern
:g/pattern/d

delete all lines not match pattern
:g!/pattern/d
:v/pattern/d
VIM 中强大的 g 命令
copy all match lines to the end of file
:g/pattern/t$

move all match lines to the end of file
:g/pattern/m$

copy all lines matching pattern to register ‘a’
qaq:g/pattern/y A

vim
2022年01月05日
1 min

Base theme for Drupal with starterkit - Glisseo

Glisseo

Features

  • Modern CSS, which includes CSS variables for styling and CSS grids for layouts!
  • Two starter themes:
    • SCSS: The SCSS based starter theme.
    • PostCSS: The PostCSS based starter theme. This one will give you full control over your styles and when they must be attached.
  • ITCSS architecture for style structure. If you're not familiar with ITCSS, it's recommended to watch this presentation by Harry Roberts (@csswizardry) to get inspired.
  • BEM methodology for template class naming. In variation of Harry Roberts (@csswizardry) as well.

The theme provides only a basic styles for HTML elements (and some Drupal specific ones), a small set of tools and a pre-organized structure. This means that you need to design the site and connect all the necessary libraries and extensions by yourself. It's a price for the flexibility and freedom that a theme gives you. It's a canvas with some important brushes.

2021年05月23日
5 mins

在 Block 中自定义 一个 Form

首先自定义一个 Form:


/**
 * @file
 * Contains \Drupal\resume\Form\WorkForm.
 */
namespace Drupal\resume\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class workForm extends FormBase {
 /**
 * {@inheritdoc}
 */
 public function getFormId() {
 return 'resume_form';
 }
 /**
 * {@inheritdoc}
 */
 public function buildForm(array $form, FormStateInterface $form_state) {
 $form['employee_name'] = array(
 '#type' => 'textfield',
 '#title' => t('Employee Name:'),
 '#required' => TRUE,
 );
 $form['employee_mail'] = array(
 '#type' => 'email',
 '#title' => t('Email ID:'),
 '#required' => TRUE,
 );
 $form['actions']['#type'] = 'actions';
 $form['actions']['submit'] = array(
 '#type' => 'submit',
 '#value' => $this->t('Register'),
 '#button_type' => 'primary',
 );
 return $form;
 }
 /**
 * {@inheritdoc}
 */
 public function submitForm(array &$form, FormStateInterface $form_state) {
 drupal_set_message($this->t('@emp_name ,Your application is being submitted!', 
array('@emp_name' => $form_state->getValue('employee_name'))));
 }
}
2019年07月12日
2 mins

understand drupal 8 service

Service: A class instance that is easily accessible and reusable by the system.

可以理解为全局静态变量,随时拿过来用。(仅做理解)

d8 中常见的一种使用情形:

\Drupal::service(‘service.name’);

一个简单实例:

my_module\my_module.services.yml

services: my.custom.service: class: \Drupal\my_module\MyService

2019年06月19日
1 min

Introduction to Drupal 8 Theme Development

一个不错的 d8 主题开发入门 PDF 教程,内容提要:

  • Anatomy of theme file system
  • Creating your first theme
  • Twig templates, and where to find them
  • Twig syntax
  • Working with template suggestions
  • Modifying content with hook_preprocess()
  • Render arrays
  • Custom templates with hook_theme()
2019年06月13日
1 min

"低保" 用英语怎么说

"老吾老,以及人之老;幼吾幼,以及人之幼。" 孟子倡导的"仁爱"精神,是中华文化的根本。2006年岁末,中国政府一"仁政"举措是 —— 明年将在全国范围内建立农村最低生活保障制度。这也是维护最广大人民群众利益的最直接的体现。

请看《中国日报》相关报道:For the first time the country's entire rural residents living in abject poverty can expect the State to cover their subsistence allowances, thanks to the government's latest move to narrow the disparities between cities and rural areas.

2019年05月13日
1 min

"国库、小金库" 用英语怎么说

外汇储备作为一个国家金融实力的标志,是充实国库、稳定本国汇率的物质基础。但是,外汇储备增长过快、规模过高也会给经济带来很多不利影响。针对目前外汇储备充实国库的现状,央行提出了三项解决措施:不再"宽进严出"、变"藏汇于国"为"藏汇于民"、鼓励企业"走出去"。

请看《中国日报》的相关报道:China has noticed the negative impacts brought by its huge foreign exchange reserves, at more than US870ドル billion, and is taking steps to relieve the pressure. The State Administration of Foreign Exchange has started to free up the country's foreign exchange regime with a shift from stockpiling foreign exchange reserves in State coffers to letting businesses and individuals hold more foreign currency.

2019年05月13日
1 min

AltStyle によって変換されたページ (->オリジナル) /