Extension:Add Metas

From MediaWiki.org

Jump to: navigation, search

         

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Add Metas

Release status: experimental

Implementation  Example
Description This extension enables you to add meta tags on all the pages like meta keywords.
Author(s)  Luis Diaz
Last Version  0.1
MediaWiki  Tested on 1.10.0
License No license specified
Download buntulug.com.ar

check usage (experimental)

Contents

[edit] What can this extension do?

This extension enables you to add meta tags on all the pages, like meta keywords

It's based on the Extension:Emoticons and Extension:MetaKeywordsTag

[edit] Usage

Just enable the require_once in LocalSettings

[edit] Installation

Just look and edit the souce, im not a PHP developer, feel free to make changes or suggestions.

[edit] Parameters

[edit] Changes to LocalSettings.php

require_once("$IP/extensions/AddMetas.php");

[edit] Code

<?php
if( !defined( 'MEDIAWIKI' ) ) {
    echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
    die( 1 );
}
 
$wgExtensionCredits['other'][] = array( 
    'name' => 'Add metas', 
    'status' => 'experimental',
    'author' => 'Luis Diaz',
    'version' => '0.1',
    'url' => 'http://www.buntulug.com.ar/wiki/Add_Metas',
    'description' => 'Add some custom metas to your wiki pages.',
);
 
$wgHooks['OutputPageBeforeHTML'][] = 'wfAddMetas';
 
function wfAddMetas( &$out, &$text ) {
  global $wgTitle, $wgParser, $wgRequest, $action;
  if(
          $action !== 'edit'
       && $action !== 'history'
       && $action !== 'delete'
       && $action !== 'watch'
       && strpos( $parser->mTitle->mPrefixedText, 'Special:' ) === false
       && $parser->mTitle->mNamespace !== 8
  )
  {
    $name = $wgTitle->getPrefixedDBKey();
 
    $out->addMeta( 'Description', 'you meta description');
    $out->addMeta( 'Keywords', $name.', your meta keywords' );
    //$out->addMeta( 'Author', 'the author');
    //$out->addMeta( 'Rating', 'General');
    //$out->addMeta( 'Revisit', '1 DAYS');
    //$out->addMeta( "revisit-after", "5 days");
  }
  return true;
}
 
?>

[edit] Problems

This can appear:

Warning: Cannot modify header information - headers already sent by (output started at /home/quintena/domains/jetairflyvirtual.com/public_html/wikipedia/extensions/AddMetas.php:43) in /home/quintena/domains/jetairflyvirtual.com/public_html/wikipedia/includes/WebResponse.php on line 16

What to do? -> under construction