snipt

Ctrl+h for KB shortcuts

PHP

Drupal preprocess html to include page-404 class when page not found

1
2
3
4
5
6
7
8
<?php
MYTHEME_preprocess_html($vars) {
	// add body class when page is not found
	$status = drupal_get_http_header("status");
	if($status == '404 Not Found'){
		$vars['classes_array'][] = 'page-404';
	}
}
https://snipt.net/embed/0c3d96224ce70fead29fc13ab0782936/
/raw/0c3d96224ce70fead29fc13ab0782936/
0c3d96224ce70fead29fc13ab0782936
php
PHP
8
2019-06-16T11:06:37
True
False
False
Jun 24, 2014 at 12:30 AM
/api/public/snipt/87195/
drupal-preprocess-html-to-include-page-404-class-when-page-not-found
<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 class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">MYTHEME_preprocess_html</span><span class="p">(</span><span class="nv">$vars</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">// add body class when page is not found</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$status</span> <span class="o">=</span> <span class="nx">drupal_get_http_header</span><span class="p">(</span><span class="s2">&quot;status&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">if</span><span class="p">(</span><span class="nv">$status</span> <span class="o">==</span> <span class="s1">&#39;404 Not Found&#39;</span><span class="p">){</span> </span><span id="L-6"><a name="L-6"></a> <span class="nv">$vars</span><span class="p">[</span><span class="s1">&#39;classes_array&#39;</span><span class="p">][]</span> <span class="o">=</span> <span class="s1">&#39;page-404&#39;</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a> <span class="p">}</span> </span><span id="L-8"><a name="L-8"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
404, drupal, php, theming

Bash Session

Install Drupal Drush in Webfaction

1
2
3
4
5
cd ~
wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
tar zxvf drush-7.x-5.9.tar.gz
ln -s ~/drush/drush ~/bin/drush
rm drush-7.x-5.9.tar.gz
https://snipt.net/embed/f32b14c4665e3b47db22cf84950ef8cb/
/raw/f32b14c4665e3b47db22cf84950ef8cb/
f32b14c4665e3b47db22cf84950ef8cb
shell-session
Bash Session
5
2019-06-05T06:18:21
True
False
False
/api/public/snipt/73008/
install-drupal-drush-in-webfaction
<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="go">cd ~</span> </span><span id="L-2"><a name="L-2"></a><span class="go">wget http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz</span> </span><span id="L-3"><a name="L-3"></a><span class="go">tar zxvf drush-7.x-5.9.tar.gz</span> </span><span id="L-4"><a name="L-4"></a><span class="go">ln -s ~/drush/drush ~/bin/drush</span> </span><span id="L-5"><a name="L-5"></a><span class="go">rm drush-7.x-5.9.tar.gz</span> </span></pre></div> </td></tr></table>
drupal, drush, webfaction

Text only

Drupal jquery document.ready() no conflict version

1
2
3
4
5
6
7
(function ($) {
    $(function() {

		// Your code here

    });
})(jQuery);
https://snipt.net/embed/3750afb6a9ed2604dd1d5018332ffdad/
/raw/3750afb6a9ed2604dd1d5018332ffdad/
3750afb6a9ed2604dd1d5018332ffdad
text
Text only
7
2019-06-09T21:38:46
True
False
False
/api/public/snipt/66340/
drupal-jquery-documentready-no-conflict-version
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>(function ($) { </span><span id="L-2"><a name="L-2"></a> $(function() { </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a> // Your code here </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a> }); </span><span id="L-7"><a name="L-7"></a>})(jQuery); </span></pre></div> </td></tr></table>
drupal, javascript