Skip to content

Instantly share code, notes, and snippets.

@crittermike
crittermike / get_node_by_path.php
Created September 16, 2016 15:15 — forked from thagler/get_node_by_path.php
Drupal 8 Get node ID by path alias
<?php
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
@aklump
aklump / node_edit_form_d8.php
Last active August 22, 2018 06:43
Programmatically embed a node or entity edit form in Drupal 8
// Without the use of D.I.
$form = \Drupal::service('entity.manager')
->getFormObject('node', 'default')
->setEntity($node);
$build[] = \Drupal::formBuilder()->getForm($form);
// Within a class using D.I.
class someClass {
public function __construct(EntityManagerInterface $entityManager) {
$this->entityManager = $entityManager;
@zetagraph
zetagraph / gulp-drupal-theme
Created November 15, 2014 20:09
gulp drupal theme
var gulp = require("gulp");
var sass = require("gulp-sass");
var filter = require('gulp-filter');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require("browser-sync");
var reload = browserSync.reload;
var shell = require('gulp-shell');
// sass task
gulp.task('sass', function () {
@wizonesolutions
wizonesolutions / README.md
Last active April 10, 2017 15:26
Drupal script to fix field collection items associated with multiple entities due to Content Translation/Node Clone bug.

Explanation

Drupal script to fix field collection items associated with multiple entities due to Content Translation/Node Clone bug.

**NOTE: This update hook gives every field collection item found to be associated with more than one node a new item_id. I haven't experienced any problems with doing this, but if you are doing anything special in your use case with the item_ids or revision_ids of field collection items, you should test thoroughly after running this update.

You should test thoroughly anyway, really.

TAKE A BACKUP.

How to use

@mpezzi
mpezzi / elb.aws.settings.inc
Created April 18, 2012 13:17
Drupal - Amazon Elastic Load Balancer HTTPS Settings
<?php
/**
* @file
* Amazon Elastic Load Balancer Settings.
*
* Force server to use https:// path if SSL is handled at load balancer.
*
* @see http://drupal.org/node/185161#comment-5452038
*/