snipt

Ctrl+h for KB shortcuts

PHP

Render views in drupal5

1
2
3
4
5
6
<?php
$view_name = 'NAMEOFVIEW'; //name of view
$view_args = array($ARG) ; //agrument
$view = views_get_view($view_name);
print views_build_view('embed', $view, $view_args, $view->use_pager, $view->nodes_per_page);
?>
https://snipt.net/embed/6ac32c2938022ec4793697bd5d66dffd/
/raw/6ac32c2938022ec4793697bd5d66dffd/
6ac32c2938022ec4793697bd5d66dffd
php
PHP
6
2019-08-19T10:11:35
True
False
False
/api/public/snipt/5157/
render-views-in-drupal5
<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></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">$view_name</span> <span class="o">=</span> <span class="s1">&#39;NAMEOFVIEW&#39;</span><span class="p">;</span> <span class="c1">//name of view</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$view_args</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="nv">$ARG</span><span class="p">)</span> <span class="p">;</span> <span class="c1">//agrument</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$view</span> <span class="o">=</span> <span class="nx">views_get_view</span><span class="p">(</span><span class="nv">$view_name</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="k">print</span> <span class="nx">views_build_view</span><span class="p">(</span><span class="s1">&#39;embed&#39;</span><span class="p">,</span> <span class="nv">$view</span><span class="p">,</span> <span class="nv">$view_args</span><span class="p">,</span> <span class="nv">$view</span><span class="o">-&gt;</span><span class="na">use_pager</span><span class="p">,</span> <span class="nv">$view</span><span class="o">-&gt;</span><span class="na">nodes_per_page</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
drupal5, php, views