Mercurial > hg > rr-repo
annotate sites/all/modules/views/help/embed.html @ 0:ff03f76ab3fe
initial version
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Wed, 21 Aug 2013 18:51:11 +0100 |
parents | |
children |
rev | line source |
---|---|
danielebarchiesi@0 | 1 You can easily embed the results of a view into other parts of your site; |
danielebarchiesi@0 | 2 either with code as a module, or in nodes or blocks as snippets. The |
danielebarchiesi@0 | 3 easiest way is to use the function <strong>views_embed_view()</strong>: |
danielebarchiesi@0 | 4 |
danielebarchiesi@0 | 5 <code>/** |
danielebarchiesi@0 | 6 * Embed a view using a PHP snippet. |
danielebarchiesi@0 | 7 * |
danielebarchiesi@0 | 8 * This function is meant to be called from PHP snippets, should one wish to |
danielebarchiesi@0 | 9 * embed a view in a node or something. It's meant to provide the simplest |
danielebarchiesi@0 | 10 * solution and doesn't really offer a lot of options, but breaking the function |
danielebarchiesi@0 | 11 * apart is pretty easy, and this provides a worthwhile guide to doing so. |
danielebarchiesi@0 | 12 * |
danielebarchiesi@0 | 13 * @param $name |
danielebarchiesi@0 | 14 * The name of the view to embed. |
danielebarchiesi@0 | 15 * @param $display_id |
danielebarchiesi@0 | 16 * The display id to embed. If unsure, use 'default', as it will always be |
danielebarchiesi@0 | 17 * valid. But things like 'page' or 'block' should work here. |
danielebarchiesi@0 | 18 * @param ... |
danielebarchiesi@0 | 19 * Any additional parameters will be passed as arguments. |
danielebarchiesi@0 | 20 */ |
danielebarchiesi@0 | 21 function views_embed_view($name, $display_id = 'default') { |
danielebarchiesi@0 | 22 </code> |
danielebarchiesi@0 | 23 |
danielebarchiesi@0 | 24 To figure out the id of a display, hover your mouse over the tab to select that display. Everything after the '#views-tab-' is the id of that display. This ID is guaranteed never to change unless you delete the display and create a new one. |