Extension talk:Add HTML Meta and Title
Add topicUsing v 1.9 - Adds keywords & description, but not the title
[edit]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.
Title tags don't work mediawiki 1.11.1
[edit]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)
v0.2 to v0.4
[edit]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)
Small fix to v0.2
[edit]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 <
and >
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)
Multiple META keywords tags
[edit]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)
with MW 1.12
[edit]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)
Template
[edit]Can this extension work into a template? --user
- don't know - what exactly do you mean? Владимир Радуловски 22:28, 12 December 2008 (UTC)
#tag
[edit]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)
download link unavailable
[edit]The download link is down....?
Does anyone have another link, or can someone post the extension code into this article?
Error
[edit]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!
Not working with PHP 5.3.0
[edit]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)
Duplications
[edit]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.
Duplications
[edit]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;
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.
Download site not available & is there already a v0.5 ?
[edit]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)
Velko domain used for a marketing company
[edit]I think the whole velko.org domain has been given away to a different company.
I found a copy of the original extension, and will post it on the main page.
--DonGiulio 18:07, 16 June 2010 (UTC)
Setting title does not seem to work with MW 1.16
[edit]I'm using the extension in MW 1.16. Debugging it, seems that $out->setHTMLTitle( $new_title ) does not work. Can anyone else confirm? --Toniher 17:03, 8 September 2010 (UTC)
- Yes, that's true. I have the same problem with MW 1.16. Could someone find a fix? Laurent --13:06, 9 September 2010 (UTC)
- Also confirmed here. The description and keyword tags seem to work, but the most important tag--the title tag--ain't takin' hold. Hope someone who's a more clever php hacker than I am will kindly fix and post. -Davydog 15:14, 19 November 2010 (UTC)
- One line needs to be added to Add_HTML_Meta_and_Title.php. Right before
$out->setHTMLTitle( $new_title );
- insert the following:
$out->mHTMLtitleFromPagetitle = true;
- Also, if you prefer to replace the title instead of appending to it, replace
$new_title .= ", $content";
- with
$new_title = "$content";
- Also confirmed here. The description and keyword tags seem to work, but the most important tag--the title tag--ain't takin' hold. Hope someone who's a more clever php hacker than I am will kindly fix and post. -Davydog 15:14, 19 November 2010 (UTC)
- Works perfectly, thanks a lot! Cheers, --Till Kraemer 11:45, 7 February 2011 (UTC)
- Yes, it works. BTW: removing the "&" before the $parser param of renderSEO function makes it work with php 5.3
function renderSEO( $text, $params = array(), $parser ) {
--Superxain 10:00, 14 March 2011 (UTC)
works! nice...but no title change.
[edit]I used it at goodpayer-badpayer.info, and see that is has, indeed, added metatags for keywords and description, however, it did not alter the title tag (no big deal). I'm satisfied. Good stuff!
--Tony Baldwin 15:19, 1 April 2011 (UTC)
Does not allow magic word substitution
[edit]if I use for example: <seo metakeywords="something, PAGENAME (in double curly braces)" /> the magic word is not substituted..
this page [1] suggests a fix, which I was not able to make work.
Does anyone have a solution to this problem?
fix for mediawiki 1.18 in function setupSEOParserHooks
[edit]When I tried to use this extenion with MW 1.18 I got this error: Call to a member function addMessage() on a non-object in /www/docs/wiki/extensions/Add_HTML_Meta_and_Title.php on line 30
In MW 1.17 the extension still worked, after changing &$parser to $parser in function renderSEO( $text, $params = array(), $parser )
But the function $wgMessageCache->addMessage() is already marked as deprecated in mw 1.17. In mw 1.18 it does not exist.
I modified the function like this:
function setupSEOParserHooks() { global $wgParser; $wgParser->setHook( 'seo', 'renderSEO' ); }
and put the error message directly inside
function renderSEO( $text, $params = array(), $parser ) { $msgSeo_empty_attr = 'Error: <seo> tag must contain at least one non-empty "title" or "metak(eywords)" or "metad(escription)" attribute.'; .... {return... wfMsgForContent($msgSeo_empty_attr). }
I am not sure whether this gives the error message correctly when and where needed, but at least the function works.
1.18 Code Changes
[edit]Can some one better explain the code changes above used for 1.18? If you could copy/paste the whole block of code modified instead of having fragments with ... between them it would be much appreciated so i can recreate your fix.
Thanks!
MW-1.19 support
[edit]A bit cleaned up version supporting 1.19 on github - https://github.com/MageSlayer/MW-MetaTitle
Errors with MW 1.15.1 (Call to undefined function...)
[edit]Hi,
the new "Extension:Add HTML Meta and Title" Version 0.7 dont' work in my private wiki. If I put text in my article page, i receive this error on a blan white page:
Fatal error: Call to undefined function mediawiki\suppresswarnings() in /home/html/de/wiki/extensions/AddHTMLMetaAndTitle/AddHTMLMetaAndTitle.php on line 152
- MediaWiki: 1.15.1
- PHP: 5.4.45 (cgi-fcgi)
- MySQL:5.5.40-log
How I can fix or which version should I use? Best regards
- Hi,
- go to Special:ExtensionDistributor/AddHTMLMetaAndTitle and choose the oldest version. the 1_24 should work on a Mw1.15...
- Regards,
- Dennisroczek (talk) 18:52, 16 December 2015 (UTC)
- Hi Dennisroczek,
- thanks for the fast support :)
- I tried it, but I get always an error. I tested also a version, where it works, but only without article content. In this case, if I wrote something in de article, I received an other error (not remember), with only the <meta code> it worked.
Update to extension registration
[edit]I've updated this extension to use extension.json. If anyone feels like reviewing my patch https://gerrit.wikimedia.org/r/#/c/384200/ that'd be great! :-) Thanks. Sam Wilson 04:38, 14 October 2017 (UTC)
Add line for Yandex.Webmaster
[edit]Is it possible to add a line for verification in Yandex.Webmaster?
It's necessary only to make little changes:
protected $storeKeys = [ 'yandex-verification' => 'METAYANDEXSITEVERIFICATION', ]; foreach ( $params as $name => $param ) { $commentTitle = false; if ( $name === 'yandex-verification' ) { $commentTitle = $this->storeKeys['yandex-verification']; } }
I can't make these changes by myself, because I don't understand how to change this addon.
how to add link meta like apple-touch-icon
[edit]<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon.png" /> what to do?
Giving error with Mediawiki 1.35.7
[edit]I am getting following errors with MW 1.35.7 version and I have to comment loading this extension. Is there an update to this issue?
PHP Deprecated: Required parameter $parser follows optional parameter $params in /home/vikasnd/public_html/w/extensions/AddHTMLMetaAndTitle/includes/Adder.php on line 86
PHP Deprecated: Required parameter $frame follows optional parameter $params in /home/vikasnd/public_html/w/extensions/AddHTMLMetaAndTitle/includes/Adder.php on line 86 Vikasnd (talk) 05:00, 8 August 2022 (UTC)