This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget https://github.com/drush-ops/drush/releases/download/8.1.17/drush.phar | |
chmod +x drush.phar | |
sudo mv drush.phar /usr/local/bin/drush | |
drush --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.a2hosting.in/kb/installable-applications/optimization-and-configuration/drupal2/installing-drupal-console | |
Console Install | |
composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader | |
Path | |
echo 'alias drupal="/var/www/html/<project_name>/vendor/bin/drupal"' >> ~/.bashrc | |
source ~/.bashrc | |
Command: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The drupal_set_message() function is being deprecated! | |
// @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x | |
// > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. | |
// > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. | |
// In some custom code. | |
\Drupal::messenger()->addMessage('Say something else'); | |
// When trying to print out a simple var. | |
\Drupal::messenger()->addMessage(print_r($stuff, TRUE)); | |
// In a Drupal 8 Form's submitForm() handler: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Settings.php | |
$settings['hello_world'] = 'Radheshyam Kumar Kumawat'; | |
//bartik.theme | |
function bartik_preprocess_page(&$variables) { | |
$variables['setting_name_value'] = Settings::get('hello_world', 'my drupal setting name'); | |
} | |
//page.html.twig | |
{{ setting_name_value }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\Drupal::logger('debugging2')->warning(print_r($item, TRUE)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create a new administrator account in drupal with drush | |
Create your new user: | |
$ drush user-create your_user_name --mail="[email protected]" --password="your user password" | |
Assign the role administrator to your user: | |
$ drush user-add-role "administrator" your_user_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_cron(). | |
*/ | |
function csv_uploader_cron() { | |
$end_date = strtotime(date('Y-m-d H:i:s')); | |
$start_date = strtotime(date('Y-m-d H:i:s', strtotime("-2 days"))); | |
$query = \Drupal::database()->select('node_field_data','n'); | |
$query->leftjoin('node__field_roles','r', 'n.nid=r.entity_id'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function common_mail_alter(&$message) { | |
if ($message['id'] == 'user_password_reset') { | |
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed; delsp=yes'; | |
} | |
} | |
/* Password recovery */ | |
<a href='[user:one-time-login-url]' target="_blank">Generate/Reset Password</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create block type | |
Field - Title, body, image, link, | |
help - https://medium.com/@sarahcodes/custom-block-type-for-hero-banners-in-drupal-8-7d0adb665fd3 | |
Twig Field value - https://blog.usejournal.com/getting-drupal-8-field-values-in-twig-22b80cb609bd | |
**************************************************** | |
1. themename.theme | |
/** | |
* Implements hook_theme_suggestions_HOOK_alter() for form templates. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = ''; | |
$view = views_get_view('assets_search'); | |
if($view){ | |
$view->set_display('page'); | |
$output = $view->preview('assets_search'); | |
print $output; | |
} | |
?> |