开发者

Embedding Recent Changes on Main Page on MediaWiki

开发者 https://www.devze.com 2022-12-22 08:10 出处:网络
I am a complete and total newbie with MediaWiki.I would like to find a way to include Recent Changes di开发者_C百科rectly on the Main Page, without having to have the user navigate to the recent chang

I am a complete and total newbie with MediaWiki. I would like to find a way to include Recent Changes di开发者_C百科rectly on the Main Page, without having to have the user navigate to the recent changes page. What are my options for this?

Thanks!


One way would be to put

{{Special:RecentChanges}}

in [[Main_Page]].


The News extension (available at http://www.mediawiki.org/wiki/Extension:News ) is a way to do this very simply, and can be customized so that the entire recent changes page is not displayed. Just install the extension and then adding the

<news/>

tag will include the 10 most recent changes. Parameters to change the number of items shown, exclude minor changes, or format how they are displayed are available on the website linked above.


There is also an extension : Dynamic Article List - which allows you more control over what to display in your list of recent changes.

http://meta.wikimedia.org/wiki/User:Socoljam/DynamicArticleList_%28enhanced%29

This is an enhanced version of a MediaWiki extension of the same name. It also provides slightly clearer instructions to install it and get it working.


I wanted the same thing, but in a much simpler list than the full output of {{Special:RecentChanges}}. The following database query gives just the page names of the changes in the last 30 days, without the recently deleted pages:

SELECT DISTINCT rc_title
FROM recentchanges
WHERE rc_timestamp > (CURRENT_DATE - INTERVAL '30 days')
AND rc_new_len > 0
ORDER BY rc_title

(This is with PostgreSQL. It might be slightly different with MySQL)

To put that on the Main page, I used the ExternalData extension with it's #get_db_data function.

In LocalSettings.php:

wfLoadExtension( 'ExternalData' );

$wgExternalDataSources['mydb'] = [
    'server'   => '127.0.0.1',  // or 'yourwiki.example.com',
    'type'     => 'postgres',   // mysql, postgres, sqlite, ...
    'name'     => 'wikidb',     // wiki DB name
    'user'     => 'backup_bot', // user with only "SELECT" rights
    'password' => ''
];

Then, in the Main_page:

{{#get_db_data:
 db=mydb
 |from=recentchanges
 |where=rc_timestamp > (CURRENT_DATE - INTERVAL '30 days') AND rc_new_len > 0
 |order by=rc_title
 |group by=rc_title
 |data= title=rc_title
 |suppress error
}}

Changes in the last 30 days:
{| class="wikitable"
    ! title
{{#for_external_table:<nowiki/>
      {{!}}-
      {{!}} {{{title}}}
}}
|}

Or as a simple list:
{{#for_external_table:&nbsp;
* [[{{{title}}}]]
}}
0

精彩评论

暂无评论...
验证码 换一张
取 消