/**
  * 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;
     }
 }
 /**
  * Retrieve the content object associated with this node.
  *
  * This method will return the content object associated with this node, loading it
  * if necessary, and placing it in the cache for subsequent requests.
  *
  * @param bool Optionally load all child proeprties for the content object if loading is required.
  * @param bool Optionally load all the siblings for the selected content object at the same time (a preformance optimization)
  * @param bool If loading siblings, include inactive/disabled pages.
  */
 public function &getContent($deep = false, $loadsiblings = true, $loadall = false)
 {
     if (!cms_content_cache::content_exists($this->get_tag('id'))) {
         // not in cache
         $parent = $this->getParent();
         if (!$loadsiblings || !$parent) {
             // only load this content object
             $gCms = cmsms();
             $contentops = $gCms->GetContentOperations();
             // todo: LoadContentFromId should use content cache.
             $content = $contentops->LoadContentFromId($this->get_tag('id'), $deep);
             return $content;
         } else {
             $parent->getChildren($deep, $loadall);
             if (cms_content_cache::content_exists($this->get_tag('id'))) {
                 return cms_content_cache::get_content($this->get_tag('id'));
             }
         }
     }
     return cms_content_cache::get_content($this->get_tag('id'));
 }