Skip to content

Instantly share code, notes, and snippets.

Avatar

Juampy NR juampynr

View GitHub Profile
View CHANGELOG.md

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[Unreleased] - yyyy-mm-dd

Here we write upgrading notes for brands. It's a team effort to make them as

@juampynr
juampynr / README.md
Created May 31, 2016
Run Drupal 8 web tests without installing Drupal
View README.md
  1. Create a MySQL database.
  2. Create a user that has access to that database.
  3. Make sure that you have the PDO_MySQL PHP library (otherwise you will get an error because it is missing).
  4. Run the following script.
  5. Once tests complete, we need to stop PHP's web server.

Note: there seem to be some issues with PHP's built-in web server. Please report them here https://www.drupal.org/node/1543858.

@juampynr
juampynr / mymodule.md
Last active Mar 8, 2022
Drupal 7 Database Updates tricks
View mymodule.md

This document contains a common database updates in Drupal 7 projects.

Change a field type from textarea to textfield (wipe out its data)

Let's suppose we want to change field_article_summary from text to textarea, but we do not care about loosing its current data.

Start by removing the field through the Admin Interface in your local environment. Then, add the field with the new configuration and recreate the feature where it was exported. Finally, add the following database update:

@juampynr
juampynr / mymodule.info
Last active Feb 13, 2022
Drupal 7 Views 3 custom field handler
View mymodule.info
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_handlername.inc
@juampynr
juampynr / RoboFile.php
Last active Oct 9, 2021
Drupal 8 common migration tasks
View RoboFile.php
<?php
/**
* Command line tasks.
*
* @codingStandardsIgnoreStart
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD)
*/
class RoboFile extends \Robo\Tasks {
@juampynr
juampynr / mymodule.info
Last active Aug 10, 2021
Drupal 7 Views 3 custom filter handler
View mymodule.info
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_filter_myfiltername.inc
@juampynr
juampynr / guzzle_post.php
Last active Jul 7, 2021
Sample POST request with Guzzle
View guzzle_post.php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'http://example.com',
]);
@juampynr
juampynr / config.yml
Last active Feb 26, 2021
Sample .tugboat/config.yml for a Drupal 8 contrib project (webform). Inspired by https://github.com/q0rban/tugboat-drupal
View config.yml
services:
php:
image: q0rban/tugboat-drupal:8.8
default: true
http: false
depends: mysql
commands:
update: |
set -eux
# Check out a branch using the unique Tugboat ID for this repository, to
@juampynr
juampynr / README.md
Last active Nov 9, 2020
Make Drupal 7 not to redirect to the node display after saving it
View README.md

Drupal 7's default behavior is to redirect the user to the full display of a node after it has been saved.

If you want to stay in the edit form after saving, add this snippet to a custom module adjusting the module namespace in the two functions.

For Drupal 8 or 9, have a look at the comment below by @zanvidmar.

Acknowledgements

@juampynr
juampynr / extract_fields.php
Created Jul 17, 2020
Drupal 7: script to extract all fields
View extract_fields.php
<?php
/**
* Drupal 7 field extract script.
*
* Extracts all fields into a csv file so it can be open with Google Spreadsheet, LibreOffice, or Excel.
*
* Usage:
* 1. Save this file to the docroot.
* 2. run drush php-script exctract_fields.php