Drupal 8
Update Value Taxonomy
Update แบบ fix field นั้นๆ ว่าจะเป็นค่าอะไร
เปลี่ยน core/jqeruy ของ Drupal 8
mytheme.libraries.yml:
jquery-custom:
remote: https://github.com/jquery/jquery
version: "2.2.4"
license:
name: MIT
url: https://github.com/jquery/jquery/blob/2.2.4/LICENSE.txt
gpl-compatible: true
js:
js/jquery-2.2.4.min.js: { minified: true, weight: -20 }
mytheme.info.yml:
libraries-override:
# Replace an entire library.
core/jquery: mytheme/jquery-custom
Install Drush on Mac ox for Drupal 8
wget https://github.com/drush-ops/drush/releases/download/8.1.18/drush.phar
chmod +x drush.phar && mv drush.phar /usr/local/bin/drush
ฟังชั่น เช็คโมดูล เปิดอยู่หรือเปล่า
Drupal 7
if (module_exists('blog')) {
echo 'blog module is enabled';
}
Drupal 8
\Drupal::moduleHandler()->moduleExists($module);
Load Name Taxonomy from tid
Drupal 7
เราใช้ ฟังชั่น taxonomy_term_load()
สำหรับ tid ตัวเดียว
<?php
$term = taxonomy_term_load($tid);
$name = $term->name;
?>
สำหรับ หรับ tid หลายตัว
<?php
$tids = array(1, 2, 3);
$terms = taxonomy_term_load_multiple($tids);
foreach ($terms as $term) {
$name = $term->name;
}
?>
Drupal - Use Drush to Export/Import a MySQL Database Dump File
Export Database to File
Drupal 6 and 7
drush cc
drush sql-dump > ~/my-sql-dump-file-name.sql
drush sql-dump --gzip --result-file=backupdbsite.sql
Drupal 8
วิธี get base url ของ Drupal 8
$host = \Drupal::request()->getHost(); ==> drupal.dev
$host = \Drupal::request()->getSchemeAndHttpHost(); ==> http://drupal.dev
ใช้งาน Token replace
$token = \Drupal::token(); $message_html = "hello [current-page:title] ----- [amount-node:amount:2]"; // Replace the token for subject. $email_auth = $token->replace($message_html, array('amount-node' => $amount));
ถ้า Token มี html มันจะไม่ render html เราต้องใช้ function " htmlspecialchars_decode "
ตัวอย่าง :
htmlspecialchars_decode($email_auth);