主要记录一些琐碎的知识点。

1.“In Drupal 8 drupal_add_css()drupal_add_js() and drupal_add_library()were removed in favor of #attached

  在Drupal8中,drupal_add_css(), drupal_add_js(), 和drupal_add_library()被去除了。只支持以#attached的方式来附加css或者js。

2.PHP向js传递变量(drupalSettings)

  1)*.libraries.yml文件:

cuddly-slider:
version: 1.x
js:
js/click.js: {}
dependencies:
- core/jquery
- core/drupalSettings

  2)*.theme文件:

function fluffiness_page_attachments_alter(&$page) {
$page['#attached']['library'][] = 'fluffiness/cuddly-slider';
$page['#attached']['drupalSettings']['fluffiness']['cuddlySlider']['foo'] = 'bar';
}

  3)

$(function(){
console.log('the value is '+drupalSettings.fluffiness.cuddlySlider.foo);
})

3.在Twig模板中可以直接使用的函数:

  Functions - In Twig Templates

4.移除了theme()函数。

  

<?php
// Before - passing a string of rendered HTML to the template.
$variables['table'] = theme('table', array('header' => $header, 'rows' => $rows));
// After - passing a render array to the template.
$variables['table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
?>

5.为指定页面添加css/js库:

function fluffiness_preprocess_page(&$variables) {
$route = "entity.node.preview";
if (\Drupal::routeMatch()->getRouteName() === $route) {
$variables['#attached']['library'][] = 'fluffiness/node-preview';
}
}

6.为指定的*.html.twig模板增加库

{{ attach_library('fluffiness/cuddly-slider') }}
<div>Some fluffy markup {{ message }}</div>

Drupal8学习之路--官网文档碎碎记--主题篇的更多相关文章

  1. Unity shader 官网文档全方位学习(一)

    转载:https://my.oschina.net/u/138823/blog/181131 摘要: 这篇文章主要介绍Surface Shaders基础及Examples详尽解析 What?? Sha ...

  2. Spring Security 官网文档学习

    文章目录 通过`maven`向普通的`WEB`项目中引入`spring security` 配置 `spring security` `configure(HttpSecurity)` 方法 自定义U ...

  3. Hortonworks官网文档怎么找?

    Hortonworks官网文档怎么找? 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 俗话说,授人予鱼不如授人予渔,网上部署HDP的部署方式的博客有很多,看得你是眼花缭乱的.其实万 ...

  4. 【VR】Leap Motion 官网文档 FingerModel (手指模型)

    前言: 感谢关注和支持这个Leap Motion系列翻译的朋友们,非常抱歉因为工作原因非常久没有更新,今后这个翻译还会继续(除非官方直接给出中文文档).本篇献给大家的是 <FingerModel ...

  5. mybatis官网文档mybatis_doc

    在平时的学习中,我们可以去参考官网的文档来学习,这个文档有中文的,方便我们去阅读,而且这里的分类很详细. 官网文档链接:http://www.mybatis.org/mybatis-3/zh/inde ...

  6. 你会阅读appium官网文档吗

    高效学习appium第一步,学会查看appium官方文档.如果能把appium文档都通读一遍,对学习appium大有益处. 而能做到通读appium官方文档的人,想必不是很多,刚开始学习appium的 ...

  7. 部署openstack的官网文档解读mysql的配置文件

    部署openstack的官网文档解读mysql的配置文件(使用与ubutu和centos7等系统) author:headsen chen  2017-10-12 16:57:11 个人原创,严禁转载 ...

  8. redis过期机制(官网文档总结)

    官网地址:https://redis.io/commands/expire redis过期定义如下: Set a timeout on key. After the timeout has expir ...

  9. redis module 学习—官网文档整理

    前言 redis在4.0版本中,推出了一个非常吸引的特性,可以通过编写插件的模式,来动态扩展redis的能力.在4.0之前,如果用户想拥有一个带TTL的INCRBY 命令,那么用户只能自己去改代码,重 ...

随机推荐

  1. 调用百度地图开发平台的JavascriptAPI实现将市县位置转换成坐标

    最近的项目要做的地图比较多,有的还比较复杂,而地图用到的坐标,上网找json文件更是良莠不齐的.真是让人伤脑筋,后来突然想到了百度地图开发平台,没想到真的有对应的API哦,谢天谢地!!!下面说一下完整 ...

  2. vmware安装——CentOS-6.5和Mysql

    1.新建虚拟机 2.安装centos6.5 3.centos设置 查看网络 4.vmware设置网络连接 关闭selinux [root@china ~]# vim /etc/selinux/conf ...

  3. Ubuntu“无法打开锁文件(Could not get lock)”问题解决

    用apt-get安装软件时提示: 无法获得锁 /var/lib/dpkg/lock - open(11:资源暂时不可用) 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它? 其 ...

  4. postman创建mocker Server

    为了不影响前端开发的进度,一般后端都是先定数据结构,然后写个假接口让前端调用,这样前端就不必等着后端接口开发完成以后再开始了. 届时,前后端以及UI和测试就可以并行,待双方都把各自的逻辑写好了,便可以 ...

  5. Openerp负载平衡

    来自OpenERP 7.0 带来了许多新特性,架构上也有许多改进.其中可配置 worker 参数,可使 OpenERP 运行在多进程模式,突破GIL的限制,有效利用了现代多核CPU的性能.但默认情况下 ...

  6. CentOS6.5下Ambari安装搭建部署大数据集群(图文分五大步详解)(博主强烈推荐)

    第一步: Ambari安装之Ambari安装前准备(CentOS6.5)(一) 第二步: Ambari安装之部署本地库(镜像服务器)(二) 第三步: Ambari安装之安装并配置Ambari-serv ...

  7. udgrade rubygems-update

    gem install rubygems-update update_rubygems gem update --system gem install rubygems-bundler  

  8. Ubuntu系统下OpenDaylight源码编译安装

    操作系统:Linux x64 / Ubuntu 14.04 研究领域:软件定义网络SDN (Software-defined Networking) 开发组件:OpenDaylight 声明:转载请注 ...

  9. Spring Framework’s WebDataBinder

    Last week, I was just outside our nation’s capital teaching Spring Web MVC Framework to a wonderful ...

  10. win10 uwp unix timestamp 时间戳 转 DateTime

    有时候需要把网络的 unix timestamp 转为 C# 的 DateTime ,在 UWP 可以如何转换? 转换函数可以使用下面的代码 private static DateTime UnixT ...