Extension talk:TopTenPages
Add topicRestrict to namespaces
[edit]Is there any way to restrict the output to certain namespaces? --Flominator 13:07, 15 August 2007 (UTC)
- As a first workaround, you could edit this line (42) in your TopTenPages.php
WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0";
- Replace NS_MAIN by the namespace of your choice, e.g. NS_USER, NS_IMAGE, See Manual:$wgNamespacesToBeSearchedDefault for a completet list of Namspaces. Please leave the dots before and after the namespace, because they are tell the parser to connect the text-strings. If you'd like to see the most frequented discussions, you could write:
WHERE page_namespace=".NS_TALK." AND page_is_redirect=0";
- Of course, this would affect all Occurrences.
- An existing page may show the pages of the old namespace until all (Browser and Server) caches are cleared. Testing by editing a new page and looking at preview showed changes immediately.
- I just made available via variable. I'll publish it tomorrow or so.
- New Version available. Includes Namespace-Selection. For Details, see Extension-Page. --Sascha 12:52, 4 September 2007 (UTC)
User-Namespaces
[edit]Hi there, thanks for the modification above. Meanwhile I faced a new problem. I want to list pages in custom made namespaces, like the ones I definied in localSettings.php:
$wgExtraNamespaces[100] = "A";
$wgExtraNamespaces[101] = "A Diskussion";
$wgExtraNamespaces[102] = "B";
$wgExtraNamespaces[103] = "B Diskussion";
$wgExtraNamespaces[104] = "C";
$wgExtraNamespaces[105] = "C Diskussion";
Unfortunately TopTenPages didn't support it, so I had to write a quick workaround and added the following lines:
case "Calc":
$namespace_constant_no=102;
break;
case "Writer":
$namespace_constant_no=100;
break;
case "Impress":
$namespace_constant_no=104;
break;
Maybe you want to include a way to specify the namespace per number or something around those lines. Thanks, --Flominator 11:28, 10 October 2007 (UTC)
- We also needed this. Maybe you could iterate through the $wgExtraNamespaces array? --Samdutton 12:43, 25 January 2008 (UTC)
I tried to use it but I am getting error as function "wfMsgExt" not defined. Any help? this look like a good extension that I would like to use on ny WIKI but I couldnt make it to work due to that error. I have version 1.6 Any help will be highly appreciated. Thanks!!
Some cleanup? Namespaces, user and built in.
[edit]I rewrote the code to handle user namespaces and built in namespaces. Using MediaWiki 1.11.1, all the code is already there in the built-in Namespace code. I don't know about older versions. There is no longer any dependency on specific namespace strings. Replace getSQL() with the following functions:
function getNamespaceConstant( $select_namespace )
{
// Namespace::getCanonicalIndex expects lower case
$namespace_constant_no = Namespace::getCanonicalIndex( strtolower( $select_namespace ) );
if ($namespace_constant_no == NULL) {
return NS_MAIN; // default
}
return $namespace_constant_no;
}
function getSQL($select_namespace) {
$dbr =& wfGetDB( DB_SLAVE );
$page = $dbr->tableName( 'page' );
// find
$namespace_constant_no = $this->getNamespaceConstant( $select_namespace );
return
"SELECT 'TopTenPages' as type,
page_namespace as namespace,
page_title as title,
page_counter as value
FROM $page
WHERE page_namespace=".$namespace_constant_no." AND page_is_redirect=0";
}
PS: Thanks for writing this extension - saved me a lot of time!
Dangers?
[edit]- "For use in Low-Risk-Environment"
Does the above quote from disclaimer mean that there are some dangers or vulnerabilities in the extension? Or just that the author doesn't know enough to know if there are? If it is the latter, case, can anyone else weigh in? This seems like a good extension, but the disclaimer makes me wary. Smaug 15:41, 12 April 2008 (UTC)
- I'm not an expert, but I think the user just wanted to make sure he did nothing wrong. Maybe we should ask some of our experts about it. --Flominator 17:36, 14 April 2008 (UTC)
within an article?
[edit]- "Shows the most popular Pages within an article."
Should be "within a wiki" I assume? --Chriswaterguy 13:46, 21 October 2008 (UTC)
I just came here to ask the same thing??? 74.45.250.155 03:29, 13 February 2009 (UTC)
Does it not self-update?
[edit]I have this working on the main page to my Wiki, and while it counts up okay, it will only refresh the counts when I update the page.
Does anybody else have this issue (if it is an issue)? Or, does anybody have a fix?
Cheers!
It happens exacly the same ting to me... some pages update fine but not on the Main page
Miguel Galego
--195.245.189.166 15:42, 7 April 2010 (UTC)
Try changing this:
function renderTopTenPages( $input, $argv ) {
To this:
function renderTopTenPages( $input, $argv, $parser ) {
$parser->disableCache();
How to list only new article?
[edit]Hi this extension is very useful, but is it possible to load only new articles created less than 7 days? Keep showing the most popular articles of all time may mean that the list will rarely change, and users will not know any new popular articles. --Dullmau 13:45, 10 June 2010 (UTC)
Warning: Conflicts with Extension:CurrentUsers
[edit]I'm unsure of the conflict, though I do know that using Extension:CurrentUsers on the same page as the TopTenPages code causes the latter to fail. This is easily resolved by not having Template:CurrentUsers on the same page. ^^ -- JoJo 14:28, 3 August 2010 (UTC)
Main Page
[edit]How do I remove the main page of the top ten list? Thanks! --177.19.24.22 17:41, 30 November 2011 (UTC)
Problem solved.
line 104: WHERE page_namespace=".$namespace_constant_no." AND page_is_redirect=0 AND page_id <> 1";
It appears the code has changed since this problem was resolved. There isn't a line 104. Can someone provide another solution? Thanks. -update 06/20/2014. The solution provided below works. Thank you so much!
To exclude home page, add this code inside the class:
SpecialTopTenPages.php
function getQueryInfo() { return array( 'tables' => array( 'page' ), 'fields' => array( 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_counter' ), 'conds' => "page_is_redirect = 0 AND page_id != 1 AND page_namespace = '".MWNamespace::getContentNamespaces()."'" ); }
The above solution did not work for me. I had to use the following getQueryInfo() changes to override HitCounters\SpecialPopularPages:
MediaWiki 1.26alpha (afdbf42) 10:50, 2 September 2015
function getQueryInfo() { global $wgDBprefix; return array( 'tables' => array( 'page', 'hit_counter' ), 'fields' => array( 'namespace' => 'page_namespace', 'title' => 'page_title', 'value' => 'page_counter' ), 'conds' => array( 'page_is_redirect' => 0, 'page_namespace' => MWNamespace::getContentNamespaces(), $wgDBprefix . 'page.page_id != 1' ), 'join_conds' => array( 'page' => array( 'INNER JOIN', $wgDBprefix . 'page.page_id = ' . $wgDBprefix . 'hit_counter.page_id' ) ) ); }
- Note that for most people, these modifications are not necessary, since the Main Page is almost always the most popular. You can just use:
<TopTenPages offset=1/>
--Ike @ WikiWorks 21:00, 8 September 2015 (UTC)
- Using offset=1 displays a numbered list that starts with a #2. If you want your top ten list to start with a #1, use the above method.
mediawiki 1.19
None of the above worked for me, perhaps due to a different version of the extension or mediawiki itself. I used the following getQueryInfo() implementation:
SpecialTopTenPages.php
function getQueryInfo() { return array ( 'tables' => array( 'page' ), 'fields' => array( 'page_namespace AS namespace', 'page_title AS title', 'page_counter AS value'), 'conds' => "page_is_redirect = 0 AND page_id != 1 AND page_namespace = '".MWNamespace::getContentNamespaces()."'" ); }
Strict Standards error
[edit]If you are getting a Strict Standards error, modify line 258:
function getSQL() {
change to:
function getSQL($select_namespace) {
--Tosfos (talk) 19:23, 9 May 2012 (UTC)
White screen of death
[edit]I get the white screen of death with I try to use this extension.
I am using MW 1.21.1
Thanks,
Wade
Will not work with MW>=1.25 (FIXED)
[edit]Note that Hit Counters are disabled in future MediaWiki releases, beginning with version 1.25. So this extension (and anything similar) will not work. --Ike @ WikiWorks 22:14, 15 December 2014 (UTC)
- Link to https://gerrit.wikimedia.org/r/#/c/150699/ . I updated the page to reflect this. User:Sascha / User:Krinkle, just a ping so you know about this. Multichill (talk) 11:50, 25 February 2015 (UTC)
- This now works, in conjunction with Extension:HitCounters. --Ike @ WikiWorks 18:17, 28 June 2015 (UTC)
- Shouldn't this be mentioned on the main page? It looks like this is still the case with MW 1.27.1 Potrod (talk) 03:45, 18 October 2016 (UTC)
- This now works, in conjunction with Extension:HitCounters. --Ike @ WikiWorks 18:17, 28 June 2015 (UTC)
Top 10 in a Category
[edit]Is there a way to display the top ten for a certain category?
Keep getting "Data is cached" message
[edit]Installed extension with hitcounters extension and tested with . I keep getting the following message "The following data is cached and may not be up to date. A maximum of 1,000 results are available in the cache.". What can I do to make the extension work properly?