Organizing Your Wiki's Content in MediaWiki 1.1

Exclusive offer: get 50% off this eBook here
MediaWiki 1.1 Beginner's Guide

MediaWiki 1.1 Beginner's Guide — Save 50%

Install, manage, and customize your own MediaWiki-based site

$23.99    $12.00
by Jeff Orlof Mizanur Rahman | February 2010 | MySQL Open Source PHP Web Development

In this article series by Jeff Orloff and Mizanur Rahman, authors of MediaWiki 1.1 Beginner's Guide, we will learn how to organize our content by creating namespaces that allow us to group pages with similar purposes together, and we learn how to use categories to group pages with similar content together. It also teaches us about redirecting, moving, and swapping pages around so that we can ensure when a visitor comes to our site, they find the information they are looking for because the page titles will match up with page's content. MediaWiki has many built-in features that will not only help us keep our content organized, but make it extremely easy to do this.

In this article, we will learn how to make use of these tools including:

  • How we can create Namespaces
  • How to create Categories
  • How to setup a Template for our users
  • Why we would redirect a page
  • How to move and swap a page

We have focused mainly on organizing content rather creating content in your wiki in this article. We assume you should have a few pages in your wiki. As our wiki grows in popularity, the amount of content it hosts will continue to grow so it is important to organize the content in your wiki so that our wiki looks better to our visitors and editing and reviewing content is much easier for our users. If we think of our wiki as a library, it is easy to see why we need to organize our wiki. After all, if you walk into a library with no system for organizing the books, movies, music, periodicals, and others you would find it hard to locate what you are looking for. Likewise, if we have no order in our wiki, then our visitors could find themselves frustrated when trying to find the information they are looking for. If they become too frustrated, they will go elsewhere.

Namespaces

Namespaces are used by MediaWiki to group together pages that have a similar purpose such as Help pages, User profiles, or Talk pages. This is not to be confused with pages that contain similar content. These pages are grouped by categories which we will discuss later in this article. Pages that exist within a namespace in a wiki are noted by the namespace prefix that helps to form the title of the page. For example, if we have a page called Uploading a video file that exists in the Help namespace, it would appear as Help:Uploading a video file. Perhaps you want to create a new page for an upcoming marketing project for your company. This would appear as Project: Marketing project. MediaWiki makes use of 18 built-in namespaces. The odd number namespaces are talk namespaces while even numbered ones represent subject namespaces.

Numerical index

Namespace

Description

0

Main

This groups together a majority of the site's content. There is no namespace prefix for the mainspace.

1

Talk

The discussion pages attached to the mainspace pages.

2

User

Pages that contain information about users and their history.

3

User talk

Used to leave messages to a user.

4

Project

Used for information related to the operation and development of the wiki. This is also known as the meta namespace.

5

Project talk

Used to discuss project pages.

6

File

Stores metadata for files uploaded to the wiki. This includes images, sound, video, and other files accessed through the Media namespace.

7

File talk

Used to discuss files and media.

8

MediaWiki

Contains system messages and other important content.

9

MediaWiki talk

Discussion pages related to the MediaWiki namespace.

10

Template

Used to hold templates used in the wiki.

11

Template talk

Discussion pages for the various templates used in the wiki.

12

Help

Holds help files, how-tos, and other instructions for users.

13

Help talk

Used to hold discussions related to the help files.

14

Category

Holds information related to the different categories created for the wiki.

15

Category talk

Used to hold discussions regarding the wiki's categories.

-2

Media

Used for direct linking to media files [[Media:song.ogg]] rather than the information page.

-1

Special

Groups special pages created by MediaWiki itself.

Talk pages are accessed by clicking on the discussion tab at the top of a page.

The last two namespaces, denoted by the negative sign, are used for pages created by MediaWiki. Users cannot create, delete, or edit any pages in these two namespaces without special extensions. The remaining 16 namespaces are all used for user-created content.

The following screenshot shows the Help namespace for the Joomla! documentation wiki (http://docs.joomla.org/Beginners ):

Organizing Your Wiki's Content in MediaWiki 1.1

Time for action – creating a page in a namespace

Content that is housed in many of the namespaces is created on the fly. For instance, when you first register as a user, a new page in the User namespace is created. When you create a Help page, a new page appears in the Help namespace. If you add to the discussion page for an article on your wiki, a new talk page is created. For Main, Project, Template, Help, and Category pages, we can add new pages directly into the namespace.

For example, if our IT department wanted a user manual for a new software package that was just installed, we could create a project page for this. In this instance, we would have to designate the namespace or it would default to a regular article.

  1. Open your wiki in your browser and log in.
  2. In your browser's address bar, type the following: http://www.yoursitename.com/index.php/Project:Project page name. For the example site, I will be entering: http://www.flosspropopulo.com/index.php/Project:Using our new software . Hit Enter.
  3. Your new page should open up and look similar to the following screenshot:
    Organizing Your Wiki's Content in MediaWiki 1.1
  4. Right now, the project page tab is red because the page doesn't exist yet. Click on the edit this page link to create the page.
  5. When you are satisfied with the page, click Save page.

When the page has been saved, it will look similar to this:

Organizing Your Wiki's Content in MediaWiki 1.1

You may have noticed that while the tab reads project page, the namespace is the title of our wiki. In this example, Floss Pro Populo appears instead of the word Project. As the project page deals with organization of the wiki, it defaults to the wiki's sitename to represent a project taking place within the wiki itself. This can be changed; however, it is something that should be done by more advanced MediaWiki administrators.

What just happened?

Instead of simply creating a new page, we used the URL to create a new page and included it in a specific namespace. In this example, we created a new Project page explaining the project that will include creating a user manual for a new software package. We also saw that of the 18 namespaces, we can directly create new pages using this method in only five of them. The other 13 namespaces have their pages created by MediaWiki itself when different actions are taken.

If you try to create a page in a namespace that doesn't exist, it will default to the Main namespace. MediaWiki will not create the new namespace for you.

Pop quiz – namespaces

Namespaces are important because they help keep our pages organized. As an administrator, it is important to know what kind of pages the different namespaces hold so we can find what we are looking for. To make user that you have a solid grasp of namespaces, let's take a moment to test your knowledge.

  1. All namespaces can be edited by the users.
    1. True
    2. False
  2. Most pages in the namespaces are created by MediaWiki when the user does something. Which of the following namespaces allows the user to directly create a new page (by using the URL)?
    1. Help
    2. File
    3. Special
    4. User
  3. According to the example above, which URL will correctly create a new page in the Category namespace?
    1. Category:New page
    2. http://www.wikiname.com/Category:New page
    3. http://www.wikiname.com/index.php/Category:New page
MediaWiki 1.1 Beginner's Guide Install, manage, and customize your own MediaWiki-based site
Published: March 2010
eBook Price: $23.99
Book Price: $39.99
See more
Select your format and quantity:

Creating a custom namespace

There may come a time when you feel the need to create a new namespace for your wiki. For instance, let's say that you are using MediaWiki to create a site dedicated to a user manual. In this manual, you may want to include tutorials for new users. You have the option of creating a namespace called tutorials to organize these pages where the purpose is to teach new users. A good example of this is Joomla!'s documentation site where they too have a namespace called tutorials.

Time for action – creating a new namespace

Creating a new namespace is extremely easy and requires us to go into the LocalSettings.php file and enter a few lines. That's it! As we have edited this file many times, this should be an easy task for us by now.

  1. Open the LocalSettings.php file for editing.
  2. Scroll down to the last line of the file and type:
    #Custom namespaces
    $wgExtraNamespaces[100] = "namespace";?
    $wgExtraNamespaces[101] = "namespace_talk";
  3. Substitute namespace for the name of your new namespace. In the example wiki, I used Tutorials and Tutorials_talk for the custom namespaces.
  4. Save the changes to your LocalSettings.php file.

Now, you can create a new page in your newly created namespace using the URL m

Organizing Your Wiki's Content in MediaWiki 1.1

ethod in the previous exercise.

What just happened?

As we wanted to organize some pages into a namespace called Tutorials, we needed to create a custom namespace. We did this by adding a few lines to the LocalSettings.php file, one to create the namespace itself, and another to create the associated talk page.

We also indentified each custom namespace with a numerical index. For custom namespaces, MediaWiki requires us to begin with the number 100. The namespace Tutorials was given the numerical index of 100 and its associated talk namespace, Tutorials_talk, was given 101 as talk pages use odd numbers for this.

Categories

While namespaces help us to organize a page by the purpose it serves in the wiki, we need to be able to organize the actual content as well. This is where categories come into play. Categories allow us to take content pages that are related and group them together. Unlike namespaces, which can only be created by those with access to the LocalSettings.php file, categories can be created by the wiki's users.

Time for action – creating a category

There are two ways to create a category. The first method involves using the URL and the second makes use of adding wikitext to an existing page. Once the category is created, we can add more pages to this category. As we create the category pages, you will notice that the categories, and subcategories, follow the Unicode order.

Unicode characters are:
!"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_'abcdefghijklmnopqrstuvwxyz{|}~

The first method we will use to create a category involves using the URL the same way we did to create a new page in the Project namespace earlier in this article. In this example, we will be creating a category called Office Suites in the FLOSS wiki.

  1. Open your wiki in your browser and log in.
  2. Enter the URL: http://www.wikiname.com/index.php/Category:Category name. You would substitute wiki name with the URL for your wiki and Category name with the name of your new category. For example, I enter: http://www.flosspropopulo.com/index.php/Category:Office Suites. Hit Enter when you are done. The following screenshot shows how the category page looks so far:
  3. Organizing Your Wiki's Content in MediaWiki 1.1
  4. As the category page is not yet created, you have two options. First, you can click on the create tab to create an empty category page. The second option is to click the edit this page link. Follow along with the second option and click the edit this page link.
  5. Enter some content that explains the category page.
  6. Click Show preview to see how your category page looks. If you are happy with how it reads, click Save page.
Organizing Your Wiki's Content in MediaWiki 1.1

What just happened?

Using the URL method to create a new page, we added a category to our wiki. Once the category page was created, you probably noticed that at the bottom there is a note telling you that This category currently contains no pages or media. This is because while we created a new category, we haven't added any pages or files to the category yet. In the next exercise, you will learn how to add pages to your categories.

Adding a page to a category

Some of you may remember that I said there is more than one way to create a category page. Don't worry, I haven't forgotten. We are going to learn the second way when we learn how to add a page to a category.

Time for action – add a page to a category

To add a page to a category, we need only add a small amount of wikitext to the bottom of the page: [[Category:Category name]]. That's all it takes. Now, if the category name is for a category that has not yet been created, then MediaWIki will create it for you. So there you go, the second method for creating a new category! So let's add a page to our Office Suites category in the example.

  1. Create a new page. For the example wiki, we will create a new page called OpenOffice.org.
  2. Enter the content for your page.
  3. At the bottom of the page, type the wikitext to add it to a category. For the example, we will enter [[Category:Office Suites]] at the bottom of the page.
  4. That will add the page to our Office Suites category, but what if I want to add this page to another category? After all, OpenOffice.org is available for Windows, Mac, and GNU-Linux so shouldn't it be in these categories as well? Let's take care of that right now

  5. Beneath the first category enter the syntax for each additional category. Our example will look like this when we add the other categories:
    [[Category:Office Suites]]
    [[Category:Windows software]]
    [[Category:Mac software]]
    [[Category:GNU-Linux software]]

    In this code example, I left the Office Suites category for effect. You would not need to type it in twice in your wiki.

  6. Click Show preview. If everything is as you want it to look, click Save page. Your new page will look like the following screenshot. Note the categories list at the bottom of the page.
    Organizing Your Wiki's Content in MediaWiki 1.1

What just happened?

As we created a category page in the previous exercise, we needed to add a page to it. To do so, we added a bit of wikitext to the bottom of a new page to put the page into the category. As the page we created could easily fit in other categories, we added additional Category tags to our page for the other categories. As these categories did not yet exist in our wiki, MediaWiki created them for us. Our category page for Office Suites now looks like the following screenshot:

Organizing Your Wiki's Content in MediaWiki 1.1

Have a go hero

Categories provide automatic indexes that are useful as tables of contents. The category tag lists the page on the appropriate category page automatically, and also provides a link at the bottom of the page to the category page. Go ahead and add categories to the pages you have created for your own wiki to better organize the content that you have already created.

To further organize your content, add categories to your category pages to create subcategories. No special syntax is needed, just use the category tag [[Category:Category name]]!.

Finding categories
You can view the category list on your wiki by clicking on the Special pages link in the tool box. In the Lists of pages section, you will find the Categories link. Click on this to view all the categories created in your wiki.

>> Continue Reading: Organizing Your Wiki's Content in MediaWiki 1.1- An Extension

If you have read this article you may be interested to view :

MediaWiki 1.1 Beginner's Guide Install, manage, and customize your own MediaWiki-based site
Published: March 2010
eBook Price: $23.99
Book Price: $39.99
See more
Select your format and quantity:

About the Author :


Jeff Cochran

Jeff Cochran is a Senior Network Specialist for the City of Naples, Florida. A large part of his job includes web design and coding, as well as web server management. Jeff has nearly two decades of experience with the Internet, having started one of the first Internet Service Providers in Southwest Florida, and has worked with Windows and Unix-based web servers. Now primarily concentrating on Windows technologies, Jeff has been a Microsoft MVP for Microsoft's Internet Information Server for nearly a decade and is active in the ASP Classic and ASP.NET communities as well.

Jeff has been married for twenty years to Zina, a graphic designer and, according to most accounts, the driving force that keeps him focused on… Oh look – A Pony! In the off-hours, Jeff and Zina spend much of their time remodeling a 1950s bungalow in Naples, Florida, trying to keep the rain out and the cats in. Jeff also has a long-term addiction to classic pinball machines, tropical fish, and off-road vehicles, all of which compete with home repairs for a share of his income.

Mizanur Rahman

Mizanur Rahman from Bangladesh is a Senior Software Engineer at Relisource Technologies (http://www.relisource.com). He loves to work with Java, PHP and other web-based technologies and is a moderator of PHPXperts, the largest PHP user group in Bangladesh.

Contact Mizanur Rahman

Books From Packt

Plone 3.3 Multimedia
Plone 3.3 Multimedia

WordPress 2.8 Themes Cookbook
WordPress 2.8 Themes Cookbook

Spring Python 1.1
Spring Python 1.1

Joomla! 1.5 Content Administration
Joomla! 1.5 Content Administration

Joomla! 1.5 SEO
Joomla! 1.5 SEO

MySQL Admin Cookbook
MySQL Admin Cookbook

JavaFX 1.2 Application Development Cookbook
JavaFX 1.2 Application Development Cookbook

Moodle 1.9 Theme Design: Beginner's Guide
Moodle 1.9 Theme Design: Beginner's Guide

No votes yet

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
f
u
N
m
B
m
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software