Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Get active language in Joomla

1
2
3
4
<?php
	$lang =& JFactory::getLanguage();
	$variable = $lang->getName();
?>
https://snipt.net/embed/c37e985de69136355c26c6c3d8e543da/
https://snipt.net/raw/c37e985de69136355c26c6c3d8e543da/
c37e985de69136355c26c6c3d8e543da
php
PHP
4
2016-12-02T11:56:39
True
False
False
May 18, 2013 at 07:27 AM
/api/public/snipt/58108/
get-active-language-in-joomla
<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></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="nv">$lang</span> <span class="o">=&amp;</span> <span class="nx">JFactory</span><span class="o">::</span><span class="na">getLanguage</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$variable</span> <span class="o">=</span> <span class="nv">$lang</span><span class="o">-&gt;</span><span class="na">getName</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
development, joomla, language

Bash

Drupal 6 update file path

1
2
3
4
5
6
7
8
/**
 * Move files from sites/default/files to /files folder (Drupal 6).
 */
function mymodule_update_6002() {
 $ret = array();
 $ret[] = update_sql("UPDATE {files} SET filepath = REPLACE(filepath, 'sites/default/files', 'files') WHERE filepath LIKE 'sites/default/files%%'");
 return $ret;
}
https://snipt.net/embed/2a2d027243b1741ca65214cc9b717105/
https://snipt.net/raw/2a2d027243b1741ca65214cc9b717105/
2a2d027243b1741ca65214cc9b717105
bash
Bash
8
2016-12-02T11:56:52
True
False
False
/api/public/snipt/28559/
drupal-6-update-file-path
<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> * Move files from sites/default/files to /files folder <span class="o">(</span>Drupal 6<span class="o">)</span>. </span><span id="L-3"><a name="L-3"></a> */ </span><span id="L-4"><a name="L-4"></a><span class="k">function</span> mymodule_update_6002<span class="o">()</span> <span class="o">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="nv">$ret</span> <span class="o">=</span> array<span class="o">()</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="nv">$ret</span><span class="o">[]</span> <span class="o">=</span> update_sql<span class="o">(</span><span class="s2">&quot;UPDATE {files} SET filepath = REPLACE(filepath, &#39;sites/default/files&#39;, &#39;files&#39;) WHERE filepath LIKE &#39;sites/default/files%%&#39;&quot;</span><span class="o">)</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a> <span class="k">return</span> <span class="nv">$ret</span><span class="p">;</span> </span><span id="L-8"><a name="L-8"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
development, drupal, mysql, php

Bash

sed search replace on mac

1
2
3
4
5
# Sed is available on Mac OS X, but the -i option requires an 
# extension, even if its non-existent. Try specifying an empty
# string before the regular expression:

sed -i '' 's/foo/foo_bar/g' *.module
https://snipt.net/embed/0dd09cdb85f7f8abde430b47c6db7bc6/
https://snipt.net/raw/0dd09cdb85f7f8abde430b47c6db7bc6/
0dd09cdb85f7f8abde430b47c6db7bc6
bash
Bash
5
2016-12-02T11:56:55
True
False
False
/api/public/snipt/25304/
sed-search-replace-on-mac
<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="c1"># Sed is available on Mac OS X, but the -i option requires an </span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># extension, even if its non-existent. Try specifying an empty</span> </span><span id="L-3"><a name="L-3"></a><span class="c1"># string before the regular expression:</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>sed -i <span class="s1">&#39;&#39;</span> <span class="s1">&#39;s/foo/foo_bar/g&#39;</span> *.module </span></pre></div> </td></tr></table>
bash, cleanup, development, sed
Copyrighted, illegal, or inappropriate content? Email [email protected].