snipt

Ctrl+h for KB shortcuts

PHP

Get Node Type from filtered text

<?php
  node_get_types('name', 'example_filtered_type');
https://snipt.net/embed/97ebcb02dea9239ec87cbd83788b9cc4/
https://snipt.net/raw/97ebcb02dea9239ec87cbd83788b9cc4/
97ebcb02dea9239ec87cbd83788b9cc4
php
PHP
2
2016-10-01T01:32:02
True
False
False
/api/public/snipt/14943/
get-node-type-from-filtered-text
<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 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">node_get_types</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;example_filtered_type&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
d6, drupal, views

PHP

Get path alias from NID

<?php 
  print(drupal_get_path_alias("node/".$data->nid))
https://snipt.net/embed/6cf8c82c6c6efe8baed6039c504b95e5/
https://snipt.net/raw/6cf8c82c6c6efe8baed6039c504b95e5/
6cf8c82c6c6efe8baed6039c504b95e5
php
PHP
3
2016-10-01T01:32:07
True
False
False
/api/public/snipt/14327/
get-path-alias-from-nid
<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 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">print</span><span class="p">(</span><span class="nx">drupal_get_path_alias</span><span class="p">(</span><span class="s2">&quot;node/&quot;</span><span class="o">.</span><span class="nv">$data</span><span class="o">-&gt;</span><span class="na">nid</span><span class="p">))</span> </span></pre></div> </td></tr></table>
d6, drupal

PHP

Drupal 6 Node Load

1
2
3
<?php
 //reference http://api.drupal.org/api/function/node_load
 $variable = node_lode(nid);
https://snipt.net/embed/b43e27d98daf22d9ef2e91cf1fc07e88/
https://snipt.net/raw/b43e27d98daf22d9ef2e91cf1fc07e88/
b43e27d98daf22d9ef2e91cf1fc07e88
php
PHP
3
2016-10-01T01:32:23
True
False
False
/api/public/snipt/13757/
drupal-6-node-load
<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 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="c1">//reference http://api.drupal.org/api/function/node_load</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$variable</span> <span class="o">=</span> <span class="nx">node_lode</span><span class="p">(</span><span class="nx">nid</span><span class="p">);</span> </span></pre></div> </td></tr></table>
d6, drupal

PHP

Drupal Link Function

1
2
3
4
5
<?php
//reference http://api.drupal.org/api/function/l/6
//l($text, $path, $options = array())
//options array explanation http://groups.drupal.org/node/11554
l('Front page',<front>);
https://snipt.net/embed/fc10395592e21d3abd03313cb16da98b/
https://snipt.net/raw/fc10395592e21d3abd03313cb16da98b/
fc10395592e21d3abd03313cb16da98b
php
PHP
5
2016-10-01T01:32:33
True
False
False
/api/public/snipt/12321/
drupal-link-function
<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 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="c1">//reference http://api.drupal.org/api/function/l/6</span> </span><span id="L-3"><a name="L-3"></a><span class="c1">//l($text, $path, $options = array())</span> </span><span id="L-4"><a name="L-4"></a><span class="c1">//options array explanation http://groups.drupal.org/node/11554</span> </span><span id="L-5"><a name="L-5"></a><span class="nx">l</span><span class="p">(</span><span class="s1">&#39;Front page&#39;</span><span class="p">,</span><span class="o">&lt;</span><span class="nx">front</span><span class="o">&gt;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
d6, drupal

PHP

Drupal Date Format

1
2
3
4
<?php
// reference http://php.net/manual/en/function.date.php for date formatting
// 'small','large',or 'medium' can replace custom to use Drupal's default settings for those time formats
format_date($timestamp, 'custom', 'D, j M, Y \a\\t G:i' );
https://snipt.net/embed/21dc1170c0a20ceff98e7c2d5299b0e7/
https://snipt.net/raw/21dc1170c0a20ceff98e7c2d5299b0e7/
21dc1170c0a20ceff98e7c2d5299b0e7
php
PHP
5
2016-10-01T01:32:38
True
False
False
/api/public/snipt/12181/
drupal-date-format
<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 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="c1">// reference http://php.net/manual/en/function.date.php for date formatting</span> </span><span id="L-3"><a name="L-3"></a><span class="c1">// &#39;small&#39;,&#39;large&#39;,or &#39;medium&#39; can replace custom to use Drupal&#39;s default settings for those time formats</span> </span><span id="L-4"><a name="L-4"></a><span class="nx">format_date</span><span class="p">(</span><span class="nv">$timestamp</span><span class="p">,</span> <span class="s1">&#39;custom&#39;</span><span class="p">,</span> <span class="s1">&#39;D, j M, Y \a\\t G:i&#39;</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
d6, drupal

PHP

Embed a View

1
2
3
<?php
 //view name, display, argument(s)
 print views_embed_view('front_page','page_2','3'); 
https://snipt.net/embed/7ee2bfa4e113677a0ede529086ab731b/
https://snipt.net/raw/7ee2bfa4e113677a0ede529086ab731b/
7ee2bfa4e113677a0ede529086ab731b
php
PHP
4
2016-09-21T18:12:55
True
False
False
/api/public/snipt/11336/
embed-a-view
<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 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="c1">//view name, display, argument(s)</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">print</span> <span class="nx">views_embed_view</span><span class="p">(</span><span class="s1">&#39;front_page&#39;</span><span class="p">,</span><span class="s1">&#39;page_2&#39;</span><span class="p">,</span><span class="s1">&#39;3&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
d6, drupal, views

PHP

Get filepath from fid

<?php
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
https://snipt.net/embed/74c85cd56c86db4d8d8d6dc4bbd2ecde/
https://snipt.net/raw/74c85cd56c86db4d8d8d6dc4bbd2ecde/
74c85cd56c86db4d8d8d6dc4bbd2ecde
php
PHP
2
2016-09-21T18:27:03
True
False
False
/api/public/snipt/11332/
get-filepath-from-fid
<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 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">$filepath</span> <span class="o">=</span> <span class="nx">db_result</span><span class="p">(</span><span class="nx">db_query</span><span class="p">(</span><span class="s2">&quot;SELECT filepath FROM {files} WHERE fid = %d&quot;</span><span class="p">,</span> <span class="nv">$fid</span><span class="p">));</span> </span></pre></div> </td></tr></table>
d6, drupal, views
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.