aboutsummaryrefslogtreecommitdiff
path: root/muamba.embed.inc
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-22 14:55:57 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-22 14:55:57 -0200
commit1baa58bdadaad694ec52e92829da52ae901ab466 (patch)
tree6f825f9fed0259534b0f59963d187fe40ec55c82 /muamba.embed.inc
parent01f345fc6643b010f429a761b239d9e30d1dd479 (diff)
downloadmuamba-1baa58bdadaad694ec52e92829da52ae901ab466.tar.gz
muamba-1baa58bdadaad694ec52e92829da52ae901ab466.tar.bz2
Enhanced message page
Diffstat (limited to 'muamba.embed.inc')
-rw-r--r--muamba.embed.inc45
1 files changed, 45 insertions, 0 deletions
diff --git a/muamba.embed.inc b/muamba.embed.inc
new file mode 100644
index 0000000..944dd2f
--- /dev/null
+++ b/muamba.embed.inc
@@ -0,0 +1,45 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Embed functions.
+ */
+
+/**
+ * Embeds a view.
+ *
+ * @param $viewname
+ * Name of the view.
+ *
+ * @param $args
+ * View arguments.
+ *
+ * @param $display
+ * Display to use.
+ *
+ * @param $return
+ * Whether to return a rendered view or the view object.
+ *
+ * @return
+ * Rendered view.
+ */
+function muamba_embed_view($viewname, $args, $display = 'default', $return = 'preview') {
+ $view = views_get_view($viewname);
+ $view->override_path = $_GET['q'];
+ $output = $view->preview($display, $args);
+
+ if ($return == 'preview') {
+ // Do not output empty views.
+ if ($view->result) {
+ return $output;
+ }
+ }
+ else if ($return == 'output') {
+ // Return output, even if empty result set.
+ return $output;
+ }
+ else {
+ return $view;
+ }
+}