Skip to content

Instantly share code, notes, and snippets.

View radheymkumar's full-sized avatar

Radheshyam Kumawat radheymkumar

  • PTI WebTech
  • Jaipur
View GitHub Profile
wget https://ftp.drupal.org/files/projects/drupal-8.5.6.tar.gz
tar -zxf drupal-*.tar.gz
chmod -R 777 drupal-8.5.6
rm -r drupal-8.5.6.tar.gz
mv /home/radhe/Desktop/drupal-8.5.6 /home/radhe/Desktop/d8
@radheymkumar
radheymkumar / dots_views_data()
Last active August 22, 2018 11:59
dots_views_data()
function dots_views_data() {
// Group Dots Table
$data['dots_table']['table']['group'] = t('Dots Table');
$data['dots_table']['table']['base'] = array(
'field' => 'nid',
'title' => t('Dots Table'),
'help' => t('Example table contains example content and can be related to nodes.'),
'weight' => -10,
);
@radheymkumar
radheymkumar / Drupal 8 Install Table and Add Field
Created August 22, 2018 12:00
Drupal 8 Install Table and Add Field
<?php
use Drupal\Core\Database\Database;
/**
* Implements hook_schema().
*/
function dots_schema() {
$schema['dots_table'] = [
'description' => 'dots table',
'fields' => [
'id' => [
@radheymkumar
radheymkumar / View print on TPL
Created September 6, 2018 05:12
View print on TPL
<?php
$output = '';
$view = views_get_view('assets_search');
if($view){
$view->set_display('page');
$output = $view->preview('assets_search');
print $output;
}
?>
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.
*/
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>
@radheymkumar
radheymkumar / Cron update Code
Created December 21, 2018 09:37
Cron update Code
/**
* 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');
@radheymkumar
radheymkumar / Create Admin User IN Drupal by DRUSH
Created February 21, 2019 09:02
Create Admin User IN Drupal by DRUSH
Create a new administrator account in drupal with drush
Create your new user:
$ drush user-create your_user_name --mail="your_user_email@email.com" --password="your user password"
Assign the role administrator to your user:
$ drush user-add-role "administrator" your_user_name
@radheymkumar
radheymkumar / logger drupal 8
Created March 7, 2019 14:10
logger drupal 8
\Drupal::logger('debugging2')->warning(print_r($item, TRUE));
@radheymkumar
radheymkumar / Get Setting.php Variable
Created March 13, 2019 08:42
Get Setting.php Variable
// 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 }}