aboutsummaryrefslogtreecommitdiff
path: root/muamba.embed.inc
diff options
context:
space:
mode:
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;
+ }
+}