Skip to content

Instantly share code, notes, and snippets.

View NikLP's full-sized avatar

NikLP NikLP

  • Nottingham, UK
  • 11:25 (UTC -12:00)
  • X @NikLP
View GitHub Profile
anonymous
anonymous / mytheme.theme
Created March 18, 2017 17:05
function mytheme_preprocess_user(&$variables) {
if($variables['elements']['#view_mode'] == 'full') {
/** @var $target_user \Drupal\user\Entity\User */
$target_user = $variables['user'];
$supported_projects_by_user_view = \Drupal\views\Views::getView('supported_projects_by_enlightaid_user');
$supported_projects_by_user_view->get_total_rows = TRUE;
$supported_projects_by_user_view->execute('supported_projects_by_user_block');
@annikaC
annikaC / AccountEditRedirectController.php
Created September 29, 2016 14:03
Drupal 8 redirect user to own user edit page (for use in menu links)
<?php
namespace Drupal\yourmodule\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* A controller that redirects to the current user's edit account page.
@pfaocle
pfaocle / gen-d8-salt.sh
Created March 8, 2016 09:39
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@mootari
mootari / module.php
Created August 18, 2015 13:56
Reformat menu options. #drupal #menu
<?php
function MODULE_form_node_form_after_build($form) {
$menu_form = &$form['menu'];
$menu_form = MODULE_node_form_reformat_menus($menu_form);
}
/**
* Reformats parent menu selects.
*/
@nicktoumpelis
nicktoumpelis / git-make-empty-root.sh
Last active January 22, 2024 14:03
Create an empty initial commit
git checkout --orphan temp_master
git rm -rf .
git commit --allow-empty -m 'Make initial root commit'
git rebase --onto temp_master --root master
git branch -D temp_master
@betawax
betawax / gist:1053967
Last active January 16, 2024 07:06
Git cheat sheet

Git cheat sheet

Common commands

General

Create repository:

git init