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
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);
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 6 and 7
drush cc
drush sql-dump > ~/my-sql-dump-file-name.sql
drush sql-dump --gzip --result-file=backupdbsite.sql
Drupal 8
$host = \Drupal::request()->getHost(); ==> drupal.dev
$host = \Drupal::request()->getSchemeAndHttpHost(); ==> http://drupal.dev
$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);