Extension talk:Add HTML Meta and Title

From MediaWiki.org

Jump to: navigation, search

Contents

[edit] Using v 1.9 - Adds keywords & description, but not the title

Here: http://against-the-day.pynchonwiki.com/wiki/index.php?title=Hawaii

Here's the code I added to the top of the page:

<seo title="Hawaii,Ukuleles,Pynchon" metak="hawaii,uke,ukes,ukuleles" metad="This page tracks references to Hawaii and Ukuleles in Against the Day." />

See a problem? Thanks!

Yes there is a problem - if you manage to find the fix - submit the code here.

I changed MonoBook.php, so that the <title> part is this:

<title><?php $this->text('pagetitle') ?></title>

So at least you get the page title in there and each page has a different title tag.

[edit] Title tags don't work mediawiki 1.11.1

Title tag, except others, doen't work on MediaWiki 1.11.1 Good Job Done!


Thanks! I've just tested the extension on a fresh 1.11.1 - it works fine - all of it. Give me a link to your wiki. Владимир Радуловски 02:14, 4 March 2008 (UTC)


[edit] v0.2 to v0.4

Hello, the download link points to the v0.2. May we get a link to the latest version? -- skiidoo 02:45, 13 March 2008 (UTC)

done. Владимир Радуловски 21:35, 23 April 2008 (UTC)

[edit] Small fix to v0.2

While we're on it, there's a small problem with the v0.2. In $wgExtensionCredits, the 'description' keys is:

'description'=>'Adds the <seo title="word1,word2,..." metakeywords="word1,word2,..." metadescription="word1,word2,..." /> tag so you can add to the meta keywords and HTML-title of a wiki-page. If you are lazy just use the short version: <seo title="1 , 2" metak="m1 m2,m3" metad="word1, word2"  /> .',

You should replace the < and > signs by the HTML entities &lt; and &gt; to prevent Special:Version to see its title redesigned by the extension.
-- skiidoo 02:45, 13 March 2008 (UTC)

done with htmlspecialchars() ---- Владимир Радуловски 21:41, 23 April 2008 (UTC)

[edit] Multiple META keywords tags

This extension *adds* a new META tag, so the page turns to have two META keywords tags: the one generated by the core MediaWiki software, and the one generated by this extension. Is it possible to make it that the keywords are added to the core generated tag? -- skiidoo 02:45, 13 March 2008 (UTC)

If you have time and skill - do some research and try to find a way. I don't know how to add meta words in any other way than the addmeta method. -- Владимир Радуловски 21:43, 23 April 2008 (UTC)

[edit] with MW 1.12

Hi, I'm using MediaWiki 1.12 and I have a problem using this extension. It is showing the right title, but it is not adding neither the META keywords, nor the META description, when I'm reading the HTML generated file using Firebug. You can check on : http://www.socialopedia.org --Rmatt 21:51, 17 April 2008 (UTC)

I tried the extension on a 1.12 - worked fine . Maybe yours fails because of the french words or the apostrophes... With simple english it works, with bulgarian too. Maybe it is an issue with interfering extensions - there are alot on your wiki -- Владимир Радуловски 21:45, 23 April 2008 (UTC)

[edit] Template

Can this extension work into a template? --user

don't know - what exactly do you mean? Владимир Радуловски 22:28, 12 December 2008 (UTC)

[edit] #tag

How is the correct syntax to use this extension with #tag: ?

Did not understand your Q. What is a #tag? Владимир Радуловски 12:50, 7 January 2009 (UTC)

[edit] download link unavailable

The download link is down....?

Does anyone have another link, or can someone post the extension code into this article?

[edit] Error

i get "Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/domains/klusopedia.nl/public_html/mediawiki-1.15.1/extensions/Description/Description.php:10) in /home/xxxxxx/domains/klusopedia.nl/public_html/mediawiki-1.15.1/includes/WebResponse.php on line 16"

i also get this warning when trying to install other extensions like extension:Description . What to do? Please help!

[edit] Not working with PHP 5.3.0

This extension doesn't seem to work with the newest PHP version 5.3.0. Can that be fixed? It would be a pity if I can't use this great extension anymore. --Plati123 16:13, 13 August 2009 (UTC)

[edit] Duplications

Hello, what do you think about following:

// Adds meta tags without duplications.
function addMetaTag($out, $name, $value) {
    if (!empty($out->mMetatags)) {
		$count = count($out->mMetatags);
 		for ($i = 0; $i < $count; $i++) {
			if ($out->mMetatags[$i][0] == $name){ // Exists
				$out->mMetatags[$i][1] .= ", $value";
				return; 
			}
		}         
	}
    $out->addMeta($name, $value);
    }

But it does not work with tags that are created by default.

[edit] Duplications

To fix default tags duplications, I'll move insertMeta function to BeforePageDisplay hook:

//function insertMeta( $out, $text ) {
function insertMeta( $out) {

    # Extract meta keywords
    if (preg_match_all(
        '/<!-- ADDMETAK ([0-9a-zA-Z\\+\\/]+=*) -->/m', 
		//$text       
		$out->mBodytext, 
        $matches)===false
    ) return true; 
...
    # Extract meta keywords
    if (preg_match_all(
        '/<!-- ADDMETAD ([0-9a-zA-Z\\+\\/]+=*) -->/m', 
        //$text, 
		$out->mBodytext,
        $matches)===false
    ) return true;
</code>

and use addKeyword:

    # Merge keyword data into OutputPage as meta tags
    foreach ($data AS $item) {
        $content = @base64_decode($item);
	$content = htmlspecialchars($content, ENT_QUOTES);
		
        if ($content) {
			//$out->addMeta( 'keywords', $content );
			//addMetaTag($out, 'keywords', $content );
			$out->addKeyword( $content );
		}
    }

Simon Litt 23 September 2009.

[edit] Download site not available & is there already a v0.5 ?

unfortunately, the whole website velko.org is down. from the drupal error message, I understand this is gonna last :-( Can anyone share the source code here ?

also, seeking for another download possibility, I came accross one site reporting it is using v0.5 of this extension, although only v0.4 is listed here. can someone comment on this ?

Thanks --Jhf2442 13:26, 6 November 2009 (UTC)