snipt

Ctrl+h for KB shortcuts

Bash

Drush delete multiple fields

1
2
3
// Delete multiple fields (field_A, field_B, field_C, field_D) in one go

for field in field_A field_B field_C field_D; do drush field-delete $field -y; done
https://snipt.net/embed/59d1f95dbf94075b917fd63e4e88d7cf/
/raw/59d1f95dbf94075b917fd63e4e88d7cf/
59d1f95dbf94075b917fd63e4e88d7cf
bash
Bash
3
2016-12-29T08:49:22
True
False
True
Feb 27, 2013 at 08:49 AM
/api/public/snipt/56591/
drush-delete-multiple-fields
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>// Delete multiple fields <span class="o">(</span>field_A, field_B, field_C, field_D<span class="o">)</span> in one go </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">for</span> field in field_A field_B field_C field_D<span class="p">;</span> <span class="k">do</span> drush field-delete <span class="nv">$field</span> -y<span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
drupal, drush, fields

Bash

Applying a Patch from drupal.org in 2 Seconds or Less

# cd to the git repository to which you want to apply the patch. Then type:
curl http://drupal.org/files/file.patch | git apply
https://snipt.net/embed/57162fdef21d008bf7f923777b90e14c/
/raw/57162fdef21d008bf7f923777b90e14c/
57162fdef21d008bf7f923777b90e14c
bash
Bash
2
2019-07-21T14:46:38
True
False
False
Feb 18, 2013 at 02:17 AM
/api/public/snipt/55918/
applying-a-patch-from-drupalorg-in-2-seconds-or-less
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># cd to the git repository to which you want to apply the patch. Then type:</span> </span><span id="L-2"><a name="L-2"></a>curl http://drupal.org/files/file.patch <span class="p">|</span> git apply </span></pre></div> </td></tr></table>
bash, drupal, git, terminal

Text only

Drupal add region for theme on template.php

1
2
3
4
5
6
7
8
/*
* Implements hook_system_info_alter().
*/
function your_module_name_system_info_alter(&$info, $file, $type) {
  if ($type == 'theme') {
    $info['regions']['region_machine_name'] = t('Region name');
  }
}
https://snipt.net/embed/13a8f962b90d0daa267c62800aa5dd3d/
/raw/13a8f962b90d0daa267c62800aa5dd3d/
13a8f962b90d0daa267c62800aa5dd3d
text
Text only
8
2019-07-21T04:25:54
True
False
False
/api/public/snipt/52133/
drupal-add-region-on-theme-on-templatephp
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>/* </span><span id="L-2"><a name="L-2"></a>* Implements hook_system_info_alter(). </span><span id="L-3"><a name="L-3"></a>*/ </span><span id="L-4"><a name="L-4"></a>function your_module_name_system_info_alter(&amp;$info, $file, $type) { </span><span id="L-5"><a name="L-5"></a> if ($type == &#39;theme&#39;) { </span><span id="L-6"><a name="L-6"></a> $info[&#39;regions&#39;][&#39;region_machine_name&#39;] = t(&#39;Region name&#39;); </span><span id="L-7"><a name="L-7"></a> } </span><span id="L-8"><a name="L-8"></a>} </span></pre></div> </td></tr></table>
drupal, template.php, theme

PHP

Show errors

1
2
3
4
5
//Put this in your root index.php file

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
https://snipt.net/embed/6346ee4f3b7b69ef5e88dba25aab9c21/
/raw/6346ee4f3b7b69ef5e88dba25aab9c21/
6346ee4f3b7b69ef5e88dba25aab9c21
php
PHP
5
2019-07-21T18:11:23
True
False
False
/api/public/snipt/51890/
show-errors-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">//Put this in your root index.php file</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="cp">&lt;?php</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">error_reporting</span><span class="p">(</span><span class="k">E_ALL</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="nb">ini_set</span><span class="p">(</span><span class="s1">&#39;display_errors&#39;</span><span class="p">,</span><span class="s1">&#39;On&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
drupal, error, wordpress