Extension talk:TopTenPages
From MediaWiki.org
Contents |
[edit] Restrict to namespaces
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)
[edit] User-Namespaces
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!!
[edit] Some cleanup? Namespaces, user and built in.
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!
[edit] Dangers?
- "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)
[edit] within an article?
- "Shows the most popular Pages within an article."
Should be "within a wiki" I assume? --Chriswaterguy 13:46, 21 October 2008 (UTC)

