/** * Given a content alias, load and return the loaded content object. * * @param integer $id The id of the content object to load * @param boolean $only_active If true, only return the object if it's active flag is true. Defaults to false. * @return mixed The loaded content object. If nothing is found, returns NULL. */ function &LoadContentFromAlias($alias, $only_active = false) { if (cms_content_cache::content_exists($alias)) { return cms_content_cache::get_content($alias); } $gCms = cmsms(); $db = $gCms->GetDb(); $row = ''; if (is_numeric($alias) && strpos($alias, '.') === FALSE && strpos($alias, ',') === FALSE) { $query = "SELECT * FROM " . cms_db_prefix() . "content WHERE content_id = ?"; if ($only_active == true) { $query .= " AND active = 1"; } $row = $db->GetRow($query, array($alias)); } else { $query = "SELECT * FROM " . cms_db_prefix() . "content WHERE content_alias = ?"; if ($only_active == true) { $query .= " AND active = 1"; } $row = $db->GetRow($query, array($alias)); } if ($row) { #Make sure the type exists. If so, instantiate and load if (in_array($row['type'], array_keys($this->ListContentTypes()))) { $classtype = strtolower($row['type']); $contentobj = $this->CreateNewContent($classtype); $contentobj->LoadFromData($row, TRUE); cms_content_cache::add_content($row['content_id'], $row['content_alias'], $contentobj); return $contentobj; } else { $tmp = NULL; return $tmp; } } else { $tmp = NULL; return $tmp; } }
/** * A method to indicate wether the content object for this node is cached. * * @return boolean */ public function isContentCached() { if (cms_content_cache::content_exists($this->get_tag('id'))) { return TRUE; } return FALSE; }