|
|
|
BROWSE
All Titles WordPress Web Services SOA BPEL Web Graphics & Video Web Development RAW Portugues, Espanol, Italiano, French PHP/MySQL Oracle Open Source Networking & Telephony Moodle Microsoft & .NET Linux Servers jQuery Joomla! JBoss Java e-Learning e-Commerce Dynamics Drupal CRM Cookbook Content Management Beginner Guides Architecture and Analysis AJAX Future Titles Recently Published Titles |
Using Lists and Tables with MediaWiki
MediaWiki is a special software which is used to design Wikis. For any website, formatting is the key to creative and sophisticated designs. In this article by Mizanur Rahman, we will use advanced formatting components like lists and tables in MediaWiki to add content to a sample website. Using Lists with MediaWikiThe three types of lists available in HTML—unordered lists, ordered lists, and definition lists—are also available in MediaWiki. In MediaWiki, we can use both HTML and wiki syntax for creating lists. We will explore both techniques in this article. Unordered ListCreating unordered lists in MediaWiki is very simple. In order to create an unordered list in MediaWiki using wiki syntax, keep the following rules in mind:
Let's open a new page and write the following content in order to create an unordered list: * Ghost Directory - North America: Now let's click on Save page to see the unordered lists that we have created:
Now let us see how to create the same list using HTML syntax: <ul><li>Ghost Directory - North America : From the previous two examples we see that the wiki syntax definitely gives us a less hard time generating the unordered list. Ordered ListThe basic difference between unordered and ordered lists is that while we see only bullets for unordered lists, in an ordered list we will see numbers like 1,2... etc. In order to create an ordered list in MediaWiki using wiki syntax, keep the following rules in mind:
Now look at the following example in MediaWiki to create an ordered list: In order to submit your story for the Monthly Haunted story contest, you have to follow the Click on Save page to see the ordered list, which appears as shown below:
Now if the same example is created with HTML tags, we will see that the wiki syntax is much easier to apply than HTML syntax. However, there still are some places where we have to use HTML instead of wiki syntax. Take this example: we have a list of ghost sighting for the last 100 years starting from early 1900s. We want to show the sightings sequentially using the years rather than 1, 2, 3, etc. In MediaWiki all ordered lists start from 1, and we cannot define any attribute for wiki syntax. Hence it is not possible for us to start with predefined numbering. Maybe future MediaWiki versions will have something to accommodate this feature. So let's see how we can perform the task with HTML: Here is the list of ghost sightings in the last 100 years Click on Save page to see the output as shown in the following screenshot:
So, from the previous example, we see that it's better to use HTML tags in special cases, where wiki syntax is not of much help. This is the reason why MediaWiki allows the use of HTML tags for formatting. This article has been extracted from: MediaWiki Administrators’ Tutorial Guide
Definition ListAs the name suggests, a definition list contains a glossary-type listing. A Definition List is a list of terms and corresponding definitions. Definition lists are typically formatted with the terms on the left, with the definitions following on the right or on the next line. The rules to be kept in mind for creating a definition list are as follows:
Let us try an example for definition list creation using wiki syntax: ;Residual The output of the previous example will be as shown in the following screenshot:
According to our discussion so far, we have learned that in order to restart the numbering for an ordered list, or to create a new unordered list, we have to enter a line break. But what if we need to put a break in the text in the list item itself? For unordered list, the bullet item will be shown just below the line break without any notification. However, the problem will be for ordered lists since after every line break the numbering will resume from 1. Unfortunately, wiki syntax cannot help us to solve the problem here. We have to use an HTML solution for this. There are two options available for our rescue:
Now we will explore a mixture of ordered, unordered, and definition lists in a single example. Here is one demonstration of achieving the task using wiki syntax along with HTML tags: ; Ghosts: Ghosts are controversial phenomena that many believe in and many don't. The output appears like the following screenshot:
Using TablesTables are a very important formatting tool for web applications. Using tables we can create attractive designs and also organize our text and contents. Without tables, lots of things are not possible in HTML, especially advanced formatting. Even for the wiki, we need tables to format our text and images and present our content to the browser. Wiki syntax provides us the opportunity to create tables. Though the syntax is not very conventional it is still very easy to apply. The SyntaxTo create a table in MediaWiki, we need to use curly braces and a vertical line like {| |}. {| is used to open the table and |} to close the table. All the table contents will be between these two tags. This is also known as wiki-pipe syntax. Both opening and closing table syntax must reside on a separate line. No other tags apart from attributes of the tables may exist in those two lines; else the table will not be rendered properly. A few things that we must know before creating a table using wiki syntax are:
Just like the table opening and closing tags, we cannot put any other characters or symbols on the row indicating line.
Keeping these rules in mind, let us create a basic table for our Submitted Story section, where we will put the story titles, authors' names, and submission dates in a table format. Here is the code to do that: {|Now save the page and view it in the browser. We will see something similar to the following:
That looks pretty ordinary, doesn't it? The reason is that we made a very basic table. However, there are lots of things that we can do with tables. Here is the list of actions we can perform with wiki tables. Adding a CaptionMediaWiki provides us with an optional feature of adding a caption to a table. To add a caption to a table, we need to use the table caption syntax (a line followed by a plus sign |+) in the line after the table opening sign. Adding Column and Row HeadersIn order to add a row heading, we have to use the sign ! instead of |. The column heading is also done using the ! sign twice (!!) instead of |. The difference between row and column headings is that the rendering of a row heading depends on the browser-rendering option and the style defined by the author, while a column heading is always rendered bold font by the browser in order to separate it from the column contents. Let's modify the table in the Submitted Story section with what we have learned so far: {||+ Story Listing represents the table caption, while !# !! Story Title !! Author!! Submission Date represents the table column heading. Now save the page and view the page in the browser. You will see something similar to this:
Well, it looks a little better than the previous one. Is there anything else we can do to the table? Yes there is. We can define parameters for the table and cells. That means there is a lot of scope for formatting cell and table properties. This article has been extracted from: MediaWiki Administrators’ Tutorial Guide
Adding ParametersWiki syntax supports most of the HTML parameters that are also known as attributes. However, the most important attribute it supports is the style attribute, which we will be using extensively while formatting our tables and cells. The non-supported attributes and tags are very few in number. A few things that should be kept in mind while dealing with parameters are:
When we add parameters to a table we must keep a space between the parameter list and the table opening syntax. So what parameters we can define? Definitely we can define many parameters such as color, width, height, border, cells pacing, cell padding, font color, font size, alignment, etc. The following example contains parameters uses such as border, height, width, background color, and font color: {| style="background:#cccc99;color:black;width:80%;" border="1" In the first line of the example, we have applied the style parameter, inside which we have defined background color and foreground color, along with the height and width of the table. After that we have defined a border for the table, cell padding and spacing for each cell, and center alignment for the table. If we move down to line 4 in the example, we will see that we have defined row properties to override the table properties defined at the first line. This is to differentiate the two adjacent rows that we can see in the image. In line 6 we have defined cell properties to make the title cell a little bit wider than other cells. Let us write down the code in our edit panel and save to see what we actually doing over here. The output for the above input will be similar to this one:
So it is a very good example to look at for major style attributes that we can apply in wiki syntax. For defining colors with names, MediaWiki supports 16 web colors defined by the HTML 4.01 specification. The list of colors is given in the following tab
SummaryIn this article, we have seen how by using Lists and Tables in MediaWiki we can organize our content. The syntax of MediaWiki is relatively simple and can be used to create attractive and sophisticated designs. If you have read this article you may be interested to view :
About the AuthorMizanur 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. Books from Packt | Want to know more about Packt's Article Network? Interested in contributing your article ideas? Please visit our FAQ for more information. See More |
| ||||||||