Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

DefaultTableAttributes

Summary: How to change the default attributes for tables created using PmWiki.Tables
Version: 2004-11-30
Prerequisites:
Status:
Maintainer: Pm
Categories: Markup, Editing

Question

How can I change the default attributes for tables created using PmWiki.Tables?

Answer

In a local configuration file, set $BlockMarkups['table'][0] to the value that you would like to be used for a table's opening <table> tag. Examples:

    $BlockMarkups['table'][0] = "<table width='100%'>";
    $BlockMarkups['table'][0] = "<table border='1'>";
    $BlockMarkups['table'][0] = 
      "<table width='100%' class='simpletable'>";

(Using width='100%' in an Internet Explorer environment can cause problems if the surrounding text block has margins. What seems to happen is IE treats the 100% as 100% of the browser width. If the left margin is, say, 20px, the table then protrudes 20px into the right margin. Other browsers don't behave this way.)

Oh yes, that's correct. I had forgotten about this misfeature of Internet Explorer. We should come up with a better default. --Pm

Discussion

PmWiki treats lines beginning with || as being table markup. A table row containing data to be displayed always has more than one || on a line; other lines consisting of only one || (at the beginning) specify the table attributes to be used for any tables that follow. If no ||-attribute line is specified, PmWiki defaults to using an attribute of width='100%'.

An administrator can choose a different default for tables by changing the value of $BlockMarkups['table'][0] as described above. For example, to have tables default to 50% width with a 1-pixel border, an administrator would add the following to local/config.php:

    $BlockMarkups['table'][0] =
      "<table width='50%' border='1'>";

Note that this does not prevent an author from overriding the defaults by using the ||-attribute markup as described above. To disable authors' ability to change the table attributes, add the following to the customization:

    Markup('^||', '>^||||');

See Also

Contributors

  • Pm, 2004-11-30
Edit - History - Print - Recent Changes - Search
Page last modified on March 12, 2008, at 09:46 AM