#################################################### # Use content metatags by ecomeback # Ersetzt alle globalen Metatags (Description, Keywords) mit denen # welche im Backend für einen bestimmten Content gesetzt wurden. # Sollten für einen Content keine eigenen Metatags vorhanden sein, # werden die globalen genutzt. #################################################### # #-----[ ÖFFNE ]------------------------------------------ # components/com_content/content.html.php # #-----[ FINDE ALLE ]------------------------------------------ # appendMetaTag # #-----[ ERSETZE ALLE DURCH ]------------------------------------------ # prependMetaTag # #-----[ FINDE ]------------------------------------------ # $mainframe->prependMetaTag( 'description', $row->metadesc ); $mainframe->prependMetaTag( 'keywords', $row->metakey ); # #-----[ ERSETZE DURCH ]------------------------------------------ # $mainframe->appendMetaTagX( 'description', $row->metadesc ); $mainframe->appendMetaTagX( 'keywords', $row->metakey ); # #-----[ ÖFFNE ]------------------------------------------ # includes/joomla.php # #-----[ FINDE ]------------------------------------------ # $this->addMetaTag( $name , $content ); } # #-----[ DANACH FÜGE HINZU ]------------------------------------------ # ######################################################## /** * @param string The value of the name attibute * @param string The value of the content attibute * @param bool Disable the config meta tag * @param string The value of the meta tag content spacer * rewrite global config meta tag */ function addConfigMetaTag( $name, $content, $disable=false, $spacer=',' ) { $name = trim( htmlspecialchars( $name ) ); $content = trim( htmlspecialchars( $content ) ); if(empty($name) || empty($content)) { // if content or name empty - do nothing return; } $n = count( $this->_head['meta'] ); for ($i = 0; $i < $n; $i++) { if ($this->_head['meta'][$i][0] == $name) { if ( empty($this->_head['meta'][$i][1]) ) { // if name exists and meta content is empty set global content $this->_head['meta'][$i][1] = $content; return; } if( $disable ) { // if name exists and disable global config set existing meta content only $this->_head['meta'][$i][1] = $this->_head['meta'][$i][1]; return; } else { // if name exists and global config not disable // set existing meta and then gloabal config meta content $this->_head['meta'][$i][1] = $this->_head['meta'][$i][1] . $spacer . $content; return; } } } // if meta name and meta content not exist - create $this->addMetaTag( $name, $content ); return; } ######################################################## /** * @param string The value of the name attibute * @param string The value of the content attibute * @param string The value of the assigned option * @param string The value of the assigned task * append meta tag by assignation */ function appendMetaTagX( $name, $content, $xoption='com_content', $xtask='view' ) { global $option; global $task; $name = trim( htmlspecialchars( $name ) ); $content = trim( htmlspecialchars( $content )); $option = trim(strtolower( $option )); $task = trim(strtolower( $task )); $xoption = trim(strtolower( $xoption )); $xtask = trim(strtolower( $xtask )); if( empty($name) || empty($content) ) { return; } if( empty($xoption) ) { $this->appendMetaTag( $name, $content); return; } if( empty($xtask) && !empty($option) && $option === $xoption ) { $this->appendMetaTag( $name, $content); return; } if( !empty($xtask) && !empty($task) && !empty($option) && $option === $xoption && $task === $xtask ) { $this->appendMetaTag( $name, $content); return; } return; } # #-----[ ÖFFNE ]------------------------------------------ # includes/frontend.php # #-----[ FINDE ]------------------------------------------ # $mainframe->appendMetaTag( 'description', $mosConfig_MetaDesc ); $mainframe->appendMetaTag( 'keywords', $mosConfig_MetaKeys ); # #-----[ ERSETZE DURCH ]------------------------------------------ # $mainframe->addConfigMetaTag( 'description', $mosConfig_MetaDesc ); $mainframe->addConfigMetaTag( 'keywords', $mosConfig_MetaKeys ); #HINWEIS: # $mainframe->addConfigMetaTag( 'description', $mosConfig_MetaDesc, true, ', ' ); # true lässt globale Metatags ausblenden falls Content Metatags vorhanden sind # ', ' gibt den Seperator an, durch welchen der Metatag von der globalen Config getrennt werden soll