version=pmwiki-2.2.0 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20081216 Ubuntu/8.04 (hardy) Firefox/2.0.0.19 author=Petko charset=ISO-8859-1 csum=mv question to talk host=81.65.14.164 name=PmWiki.TableDirectives rev=66 targets=PmWiki.Tables,PmWiki.TableDirectives,PmWiki.Audiences,PmWiki.PmWikiPhilosophy,PmWiki.LocalCustomizations,PmWiki.IncludeOtherPages text=(:Summary:Directives for table processing:)%0a(:Audience: authors (intermediate) :)%0a%0a(:title Table directives:)%0aThere are four directives for table processing. All must be at the beginning of a line to have any effect.%0a%0a!!![@(:table (attr...):)@]%0aGenerates a new HTML %3ctable> tag with the attributes provided in ''attr...''.%0aCloses the previous table, if any.%0aValid attributes and values are:%0a* border ''(a positive integer)''%0a* bordercolor ''(a color name or hex number; doesn't display in all browsers)''%0a* cellspacing ''(a positive integer indicating the space between cells)''%0a* cellpadding ''(a positive integer indicating the interior border of a cell)''%0a* width ''(a positive integer or percent)''%0a* bgcolor ''(a color name or hex number)''%0a* align ''(left, center or right)''%0a* summary ''(does not display; used primarily to help visually disabled people navigate)''%0a%0a!!![@(:cell (attr...):)@]%0aGenerates a new cell with the attributes given by ''attr...''. %0aCloses the previous table cell, if any.%0aIn HTML, this creates a new "%3ctd attr>" tag (and possibly %3ctable>, %3ctr>, and %3c/td> tags if they are needed to produce a valid HTML table). %0a%0a->%25note%25 '''Note:''' Placing a space after the cell markup "(:cell:) " causes subsequent text on that line to be treated as preformatted text.%0a%0aValid attributes and values are:%0a* align ''(left, center or right)''%0a* valign ''(top, middle or bottom)'' * ''see valign attribute info below''%0a* colspan ''(a positive integer)''%0a* rowspan ''(a positive integer)''%0a* bgcolor ''(a color name or hex number)''%0a* width ''(a positive integer or percent)''%0a%0a!!![@(:cellnr (attr..):)@]%0aGenerates a new cell at the beginning of the next row.%0aCloses the previous table cell, if any.%0aIn HTML, this creates a "%3ctr>%3ctd attr>" tag, and possibly %3ctable>, %3c/td>, and %3c/tr> tags if they are needed for valid HTML.%0aValid attributes and values are:%0a* align ''(left, center or right)''%0a* valign ''(top, middle or bottom)'' * ''see valign attribute info below''%0a* colspan ''(a positive integer)''%0a* rowspan ''(a positive integer)''%0a* bgcolor ''(a color name or hex number)''%0a* width ''(a positive integer or percent)''%0a%0a!!![@(:tableend:)@]%0aCloses the previous table cell and closes off any table. Generates %3c/td>, %3c/tr>, and %3c/table> tags as needed.%0a%0a!!!* valign attribute info%0aIf not already set, PMWiki will automatically include the attribute valign='top' with all [@(:cell:)@] and [@(:cellnr:)@]. PM said "Table Directives were created for layout purposes and in that case it makes the most sense for each cell (column) to have its content at the top of the row. The attribute is placed in each cell and not in the row because certain browsers didn't recognize valign='top' in the row tag.%0a%0a!! Notes%0a%0aFor the table, cell, and cellnr tags the author can specify any attributes that would be valid in the HTML %3ctable> or %3ctd> tags. Thus you can specify rowspan, colspan, etc. arguments to build arbitrary tables. However, it's not possible to nest a [@(:table:)@] inside of a [@(:cell:)@] or [@(:cellnr:)@] -- the next paragraph explains why.%0a%0aMany are likely to ask why we didn't just use the standard HTML table markup (%3ctable>, %3ctr>, %3ctd>, %3cth>) instead of creating a new markup, and allowing nested tables as a result. There are two answers: first, the HTML table markup is very ugly for naive authors (see [[PmWiki.Audiences]] and [[PmWikiPhilosophy]] #2), and second, it'd be very easy for authors to create tables that are incorrect HTML and that display incorrectly (or not at all) on some browsers. Even seasoned web professionals sometimes get the table markup wrong, so it's a bit unrealistic to expect the average author to always get it right, or to be able to read arbitrary HTML table markup that someone else has created.%0a%0a-> %25color=green%25 ''Common comment:'' Surely, the average or naive author would not be writing HTML directly, but using a tool, such as [=FrontPage=], or even [=MSWord=], to generate the HTML. This would be a lot simpler than learning even the simplest PmWiki markups.%0a>>%3c%3c%0a%0a-> %25color=green%25 ''Pm's Response:'' And once the HTML has been generated and posted, how is someone else going to edit or modify the table if they don't have the original [=FrontPage or MSWord=] file used to create it? Remember that we're talking about ''collaborative'' authoring. The HTML that those packages generate is among the hardest to read and edit of all!%0a%0aIt's difficult to write the code needed to make PmWiki understand and fix arbitrary table markup, so PmWiki uses the simplified version above. Still, this version is able to handle most table requirements (with the possible exception of nested tables).%0a%0aAnd, this is not to say that nested HTML tables are impossible in PmWiki --they just can't be easily created by wiki authors using the default wiki markup. A site administrator can of course create header/footer HTML code and other [[local customizations]] that make use of nested tables.%0a%0a!!!Example 1. A table using table directive markup.%0a%0a"[@ @]" is a non-breaking space in html. Place it in a cell if a cell is to be empty or the border of the cell will not be drawn properly.%0a%0a(:markup:)%0a(:table border=1 cellpadding=5 cellspacing=0:)%0a(:cell:) a1%0a(:cell:) b1%0a(:cell:) c1%0a(:cell:) d1%0a(:cellnr:) a2%0a(:cell:) b2%0a(:cell:) c2%0a(:cell:)  %0a(:tableend:)%0a(:markupend:)%0a%0a%0aIn HTML, this is the same as%0a%0a-> [@%0a%3ctable border='1' cellpadding='5' cellspacing='0'>%0a %3ctr>%0a %3ctd>a1%3c/td>%0a %3ctd>b1%3c/td>%0a %3ctd>c1%3c/td>%0a %3ctd>d1%3c/td>%0a %3c/tr>%0a %3ctr>%0a %3ctd>a2%3c/td>%0a %3ctd>b2%3c/td>%0a %3ctd>c2%3c/td>%0a %3ctd> %3c/td>%0a %3c/tr>%0a%3c/table>%0a@]%0a%0a%0a-----%0a!!!Floating Table with bulleted navigation list%0a%0aWhat if you wanted to create a nice little table like a table of contents in a page like this? In this example, the table is floating right and contains some links in a bulleted list. This is a nice demonstration of how it's possible to build a little table of contents in the page, which might navigate to other pages just within the same wiki group. Note that having a bulleted list ''won't work in a ordinary table'' - it only works inside an table created with table directives such as the example code used here.%0a%0a(:markup:)%0a(:table border=1 width=30%25 align=right bgcolor=#cccc99 cellspacing=0 :)%0a(:cellnr:)%0a'''Navigation Links'''%0a(:cellnr:)%0a*[[Tables]]%0a*[[Table directives]]%0a(:tableend:)%0a(:markupend:)%0a%0a(:markup:)%0a(:table border=1 width=30%25 align=right bgcolor=#cccc99 cellspacing=0 :)%0a(:cellnr colspan=2 align=center:)%0a'''Navigation Links'''%0a(:cellnr align=center:)%0a[[Tables]]%0a(:cell align=center:)%0a[[Table directives]]%0a(:tableend:)%0a(:markupend:)%0a%0aLooking at the markup here, notice that we have used a #cccc99 hex color for the table background. Also, the [@(:cellnr:)@] markup creates a new row, a new cell and closes the row at the end.%0a%0aYou could take this concept a little further: since you might want each page in the group to contain the same table of contents, you can make ONE table like the above and put it in its own page. Then use an [[include (other pages)]] on any of your pages and bring in the table. The float (align) property will be honored in each page where it's included.%0a%0a>>faq%3c%3c [[#faq]]%0a%0aQ: Can I define table headers using the table directive markup?%0aA: No, but you can with [[Cookbook:AdvancedTableDirectives]]. See [[PITS:00535#pmanswer|Pm's reply]] to pending [[PITS:00535]]%0a%0aQ: Is it possible to do nested tables?%0aA: Yes, if you nest simple tables inside advanced tables. See also [[Cookbook:AdvancedTableDirectives]].%0a%0aQ: Is it possible to add background images to tables and table cells?%0aA: Yes, see [[Cookbook:BackgroundImages]].%0a time=1235240130 title=Table directives