Extension:DailyFeaturedPage

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
DailyFeaturedPage
Release status: stable
Implementation Tag
Description Lets you show desired article content on different days in the same location.
Author(s) Peter C. (Peter321talk)
Latest version 1.0 (2013-08-24)
MediaWiki 1.18+
Database changes No
License GPL
Download
Tags
<dailyfeaturedpage>
Hooks used
ParserFirstCallInit
Translate the DailyFeaturedPage extension if it is available at translatewiki.net
Check usage and version matrix.

The DailyFeaturedPage extension lets you show desired article content on different days in the same location. For example, lets say on your main page, you want to showcase content from selected articles and rotate different article text each day, you can use this extension to program a different article text to appear each day ("the daily featured page"). You can also use modify this extension by using other PHP date functions so that the featured page content is shown on an hourly or minutely basis.

Installation[edit]

  1. To try out this extension, create 2 new article pages, with the names "Apples" and "Oranges". In the Apples article, add this content text: <onlyinclude>My apples content to show in the daily featured page section</onlyinclude> This content will not show on the daily featured page location. In the Oranges article, add this content text: <onlyinclude>My oranges content to show in the daily featured page section</onlyinclude> This content will not show on the daily featured page location.
  2. Save dailyfeaturedpage.php to a temporary location on your computer. Use an editor such as Notepad++ to edit the dailyfeaturedpage.php file and edit these lines:case date("2013-08-01"): $featuredArticle[0] = "Apples"; break; case date("2013-08-02"): $featuredArticle[0] = "Oranges"; break; In the lines that say case date("2013-08-01"): and case date("2013-08-02"): change the dates to the dates you want. For example, if today's date is September 1, 2015, change to case date("2015-09-01"): and case date("2015-09-02"): Also add more case statements for additional articles you want to show for future dates. When you have made the changes, save the dailyfeaturedpage.php file and move the file into your mediawiki extensions folder.
  3. Add the <dailyfeaturedpage> </dailyfeaturedpage> tags to the location where you want to see the content of the daily featured page. Refresh this location and you should see the Apples content in the location where you inserted the <dailyfeaturedpage> </dailyfeaturedpage> tags.

Usage[edit]

Drop the tag dailyfeaturedpage in the locations that you want to show the article content. Your wiki page will automatically rotate to show different article content on each day. See installation section.

Customisation[edit]

You can customize the start time to start at hours or minutes by adding a statement like this:

$startDate = date('Y-m-d');
$currTime = date('H:i:s');

//At rollover to midnight set to 23:59:59
$newDay = date('H:i:s', mktime(23,59,59));

//Oranges article text will show between 18:20 and 23:59 on August 1, 2013
if ($startTime >= new DateTime("2013-08-01 18:20:00") && $currTime < $newDay) 
{
		$featuredArticle[0] = "Oranges";
}

You can also use this extension with other transclusion tags. For more info about transclusions see [1] If you want to show the entire article in the wiki location where you inserted the dailyfeaturedpage tag, then you don't need to add transclusion tags to the original articles.