Drupal

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

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

"福利彩票" 用英语怎么说

法国人曾这么描述"福利彩票":政府发行彩票是向公众推销机会和希望,公众认购彩票则是微笑纳税。据悉,去年中国福利彩票共销售约495亿多元人民币,筹集福彩公益金170多亿元。其中,公益金除部分上缴国家财政外,全部用于社会福利事业。

请看《中国日报》相关报道:The sale of China Welfare Lottery, the only national lottery approved by the Chinese government, hit a record high of 49.5 billion yuan (6.2 billion U.S. dollars) in 2006, up 20 percent from the previous year Half of the money has been turned over to the coffer of the central government. The remaining funds were used for social welfare purposes.

2019年05月13日
1 min

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