Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

PHP path arguments for block visibility in Drupal 7

1
2
3
4
5
6
7
8
<?php
global $user;
$uid = $user->uid; // Get the logged in user id
// If the path is 'mypath/myarg' the arg(0) is the 'mypath' and arg(1) is 'myarg'.
$show = (arg(0) == 'mypath') && (arg(1) == $uid); // It must both return TRUE

return $show;
?>
https://snipt.net/embed/e1421b507d61a3d3eacb1213dc44a459/
https://snipt.net/raw/e1421b507d61a3d3eacb1213dc44a459/
e1421b507d61a3d3eacb1213dc44a459
php
PHP
8
2016-12-09T02:36:40
True
False
False
Jul 23, 2013 at 05:15 PM
/api/public/snipt/69236/
php-path-arguments-for-block-visibility-in-drupal-7
<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="k">global</span> <span class="nv">$user</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$uid</span> <span class="o">=</span> <span class="nv">$user</span><span class="o">-&gt;</span><span class="na">uid</span><span class="p">;</span> <span class="c1">// Get the logged in user id</span> </span><span id="L-4"><a name="L-4"></a><span class="c1">// If the path is &#39;mypath/myarg&#39; the arg(0) is the &#39;mypath&#39; and arg(1) is &#39;myarg&#39;.</span> </span><span id="L-5"><a name="L-5"></a><span class="nv">$show</span> <span class="o">=</span> <span class="p">(</span><span class="nx">arg</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;mypath&#39;</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">arg</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="nv">$uid</span><span class="p">);</span> <span class="c1">// It must both return TRUE</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="k">return</span> <span class="nv">$show</span><span class="p">;</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
"drupal 7", block, php, visibility

Text only

Drupal: Panelizer, "Additional uncaught exception thrown while handling exception."

Just add max_allowed_packet = 20M to your my.ini (or my.cnf) file and try again
https://snipt.net/embed/a3a3103587dba1793932e03a77f373d2/
https://snipt.net/raw/a3a3103587dba1793932e03a77f373d2/
a3a3103587dba1793932e03a77f373d2
text
Text only
1
2016-12-09T09:38:01
True
False
True
Jul 20, 2013 at 05:19 PM
/api/public/snipt/68807/
drupal-panelizer-additional-uncaught-exception-thrown-while-handling-exception
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Just add max_allowed_packet = 20M to your my.ini (or my.cnf) file and try again </span></pre></div> </td></tr></table>
"drupal 7", error, panelizer

Text only

Drupal: Failed to get available update data for X projects

Empty your cache_update table and try again
https://snipt.net/embed/abc9ee4b9318a3fdfe18f4f09dca309c/
https://snipt.net/raw/abc9ee4b9318a3fdfe18f4f09dca309c/
abc9ee4b9318a3fdfe18f4f09dca309c
text
Text only
1
2016-11-30T02:51:16
True
False
True
Jul 20, 2013 at 02:06 PM
/api/public/snipt/68793/
drupal-failed-to-get-available-update-data-for-x-projects
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Empty your cache_update table and try again </span></pre></div> </td></tr></table>
"drupal 7", update

Text only

Drupal 7: View entity translation field duplicated issue

If you have a Sort Criteria on the title_field you may have your nodes appear twice.
To fix this, you just need to add a Filter Criteria on the title_field:language (Current user's language) and it works !
https://snipt.net/embed/8f519940f0965984452507bddd0000ff/
https://snipt.net/raw/8f519940f0965984452507bddd0000ff/
8f519940f0965984452507bddd0000ff
text
Text only
2
2016-12-07T01:12:54
True
False
True
Jun 12, 2013 at 06:12 AM
/api/public/snipt/63929/
drupal-7-view-entity-translation-field-duplicated-issue
<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>If you have a Sort Criteria on the title_field you may have your nodes appear twice. </span><span id="L-2"><a name="L-2"></a>To fix this, you just need to add a Filter Criteria on the title_field:language (Current user&#39;s language) and it works ! </span></pre></div> </td></tr></table>
"drupal 7", entity, field, i18n, translation, views
Copyrighted, illegal, or inappropriate content? Email [email protected].