From: Eloi G. <el...@re...> - 2003-07-06 16:46:04
|
I've figured out a way to let modules change Layout's metatags on a "per page view" basis. I'd like to hear what you guys think. I didn't have it manage the title tag because there's already a $GLOBALS['Layout_title'] to handle that, but for code conformity it can be easily modified to handle that as well. USAGE: Just assign desired tag contents to the appropriate array element. It'll clean up after itself. EXAMPLE: $_SESSION['OBJ_layout']->meta_vars['meta_description'] = 'This is the best CMS in the world!'; -Eloi George- In /mod/layout/class/layout.php add the following at line 211: /** * Content array for "one time only" meta tags specified by modules * * @var string * @access private */ var $meta_vars; then replace function getMetaTags with this one: function getMetaTags(){ $metatags = "<meta name=\"generator\" content=\"phpWebSite\" />\n"; if (isset($this->meta_vars['meta_keywords'])) $metatags .= "<meta name=\"keywords\" content=\"".$this->meta_vars['meta_keywords']."\" />\n"; elseif ($this->meta_keywords) $metatags .= "<meta name=\"keywords\" content=\"".$this->meta_keywords."\" />\n"; if (isset($this->meta_vars['meta_description'])) $metatags .= "<meta name=\"description\" content=\"".$this->meta_vars['meta_description']."\" />\n"; elseif ($this->meta_description) $metatags .= "<meta name=\"description\" content=\"".$this->meta_description."\" />\n"; if ($this->meta_robots){ switch ($this->meta_robots){ case "00": $metatags .= "<meta name=\"robots\" content=\"noindex, nofollow\" />\n"; break; case "01": $metatags .= "<meta name=\"robots\" content=\"noindex, follow\" />\n"; break; case "10": $metatags .= "<meta name=\"robots\" content=\"index, nofollow\" />\n"; break; case "11": $metatags .= "<meta name=\"robots\" content=\"index, follow\" />\n"; break; } } if (isset($this->meta_vars['meta_author'])) $metatags .= "<meta name=\"author\" content=\"".$this->meta_vars['meta_author']."\" />\n"; elseif ($this->meta_author) $metatags .= "<meta name=\"author\" content=\"".$this->meta_author."\" />\n"; if (isset($this->meta_vars['meta_owner'])) $metatags .= "<meta name=\"owner\" content=\"".$this->meta_vars['meta_owner']."\" />\n"; elseif ($this->meta_owner) $metatags .= "<meta name=\"owner\" content=\"".$this->meta_owner."\" />\n"; if (isset($this->meta_vars['meta_content'])) $metatags .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . $this->meta_vars['meta_content']."\" />\n"; elseif ($this->meta_content) $metatags .= "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . $this->meta_content."\" />\n"; /* Erase the temporary tags */ $this->meta_vars = array(); return $metatags; } |