diff --git a/lib/themefunctions.php b/lib/themefunctions.php
index 983119c..e0ea8a8 100644
--- a/lib/themefunctions.php
+++ b/lib/themefunctions.php
@@ -153,21 +153,25 @@ function get_page_url($echo = true, $slug = null) {
* @param string $name component name
* @param string $context page slug, or null for current
* @param boolean $echo default true
+ * @param string $default The content to return if the component is empty
* @return string
*/
-function get_component($name, $context = null, $echo = true) {
+function get_component($name, $context = null, $echo = true, $default = "") {
$db = getdatabase();
if ($context == null) {
$context = get_page_slug(false);
}
$pageid = $db->get("pages", "pageid", ["AND" => ["slug" => $context, "siteid" => getsiteid()]]);
$content = "";
- if (isset($_GET['edit'])) {
- $content = "
";
- }
if ($db->has("components", ["AND" => ["pageid" => $pageid, "name" => $name]])) {
$content = $db->get("components", "content", ["AND" => ["pageid" => $pageid, "name" => $name]]);
}
+ if ($content == "") {
+ $content = $default;
+ }
+ if ($content == "" && isset($_GET['edit'])) {
+ $content = "
";
+ }
if ($echo) {
echo $content;
} else {
@@ -539,4 +543,4 @@ function get_socialmedia_urls() {
}
}
return $urls;
-}
\ No newline at end of file
+}