Skip to content

Instantly share code, notes, and snippets.

View doxigo's full-sized avatar

Sohail Lajevardi doxigo

View GitHub Profile
@doxigo
doxigo / mysql8-dump-incompatibility-mariadb10-mysql57.md
Created June 4, 2021 13:53
mysql8 exported dump Unknown collation: 'utf8mb4_0900_ai_ci' error when importing back to MariaDB10.2 or Mysql 5.7

Mac:

sed -i '' 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' db.sql

@doxigo
doxigo / file-permission-wodby.md
Last active October 6, 2020 10:29
Wodby file permission issue
sudo files_chown /mnt/files/public/
sudo files_chmod /mnt/files/public/
@doxigo
doxigo / uninstall-disabled-modules.md
Created January 26, 2019 11:38
Find and uninstall disabled modules in Drupal 8
drush pm-uninstall `drush pm-list --pipe --no-core --status=disabled`
@doxigo
doxigo / autohide-show-onscroll-nav.js
Last active May 13, 2020 03:46
Automatically hide navigation on scroll down, show on scroll up for less than 767px device width
if (window.matchMedia('(max-width: 767px)').matches) {
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('header .navbar-default').outerHeight();
// on scroll, let the interval function know the user has scrolled
@doxigo
doxigo / node.twig.html
Last active July 16, 2018 13:02
A set of commonly used twig snippets for Drupal8
{# Rendering node links field #}
{{ content.links }}
{# Rendering comments #}
{{ content.comment }}
{# Rendering any field <FIELDNAME> #}
{{ content.field_FIELDNAME }}
{# Rendering node title #}
@doxigo
doxigo / template.php
Last active April 28, 2017 10:03
Translate Order Total, Billing Information in Drupal Commerce 7
function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
// Fix order total translation
if (isset($form['cart_contents'])){
$form['cart_contents']['cart_contents_view']['#markup'] = str_replace('Order total', t('Order total'), $form['cart_contents']['cart_contents_view']['#markup']);
}
// Fix translation on checkout form
if ($form['#id'] == 'commerce-checkout-form-checkout'){
if(isset($form['customer_profile_billing'])){
$form['customer_profile_billing']['#title'] = t('Billing information');
}
@doxigo
doxigo / THEMENAME.theme
Created March 9, 2017 09:48 — forked from RainbowArray/THEMENAME.theme
Change meta viewport tag in D8
<?php
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
function THEMENAME_preprocess_html(&$variables) {
foreach ($variables['page']['#attached']['html_head'] as $key => $value) {
if ($value[1] === 'viewport') {
$value[0]['#attributes']['content'] = 'width=device-width,minimum-scale=1,initial-scale=1';
$variables['page']['#attached']['html_head'][$key] = $value;
@doxigo
doxigo / fragment-of-page-html.html.twig
Created March 9, 2017 09:45 — forked from RainbowArray/fragment-of-page-html.html.twig
Need to include a node field image in the page.html.twig template with Drupal 8? This is the most straightforward way I've found to do so. (This is using the file entity module.)
{% if node.field_hero_image.entity %}
<img src="{{ file_url(node.field_hero_image.entity.uri.value) }}"
alt="{{ node.field_hero_image.alt }}"
{% if node.field_hero_image.title %}
title="{{ node.field_hero_image.title }}"
{% endif %}
/>
{% endif %}
@doxigo
doxigo / template.php
Created February 10, 2017 15:48
DRUPAL COMMERCE - TRANSLATE ORDER TOTAL, SHIPPING INFORMATION, BILLING INFORMATION
/**
* Implements hook_form_alter();
*/
function YOURTHEME_form_alter(&$form, &$form_state, $form_id) {
// Fix order total translation
if (isset($form['cart_contents'])){
$form['cart_contents']['cart_contents_view']['#markup'] = str_replace('Order total', t('Order total'), $form['cart_contents']['cart_contents_view']['#markup']);
}
// Fix translation on checkout form
if ($form['#id'] == 'commerce-checkout-form-checkout'){
@doxigo
doxigo / drupal8-new-development-process.md
Last active September 24, 2018 07:29
A Drupal 8 site building instructions to get a quick start for each new project (In case you don't already use a distribution) - The Drush Way!

Getting Started with a Drupal 8 New Website: The Drush Way!

Note: You need to have Composer, Drush, Gulp and a working DrupalConsole installed along with Git & Wget to be able to continue with this guide.

Installing Drupal Console Launcher w/o Composer

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal