News:

Join the Facebook Fan Page.

Main Menu

Tabular

Started by AzaToth, October 09, 2005, 02:42:59 AM

Previous topic - Next topic

AzaToth

Link to Mod

Tabular

Tabular is a enhanced table, it's not a replacement, but more like an addition to it.
It's at the moment nine types of styles you can use, see below for how they look like.

Styles are defined for both default theme and classic theme, without the styles it will look just like a normal table.

Only tested with 1.1 RC1

Syntax

To start a tabular type
[tabular]
...
[/tabular]


there are two optional arguments:

  • type - a number from 1 to 9 (nine different types at the moment)
  • caption - a quote enclosed bbc string as caption
a row is defined as:
[row] ... [/row]

You can have table header:
[head] ... [/head]

And table data is typed as:
[data] ... [/data]

The reason I use data, head and row instead of tr, td and th is mostly becfause SMF have in Subs-Post.php a check that will destroy the tabular code if those is used.

A full example is:


[tabular type=4 caption="[b]Table 1:[/b] My budget this month (in dollars)"]
[row] [head]Type[/head] [head]In[/head] [head]Out[/head] [head]Sum[/head] [/row]
[row] [data]Payment[/data] [data]4000[/data] [data]0[/data] [data]4000[/data] [/row]
[row] [data]Food[/data] [data]0[/data] [data]3000[/data] [data]1000[/data] [/row]
[row] [data][red]Mama[/red][/data] [data]10000[/data] [data]0[/data] [data]11000[/data] [/row]
[row] [data]Computer[/data] [data]0[/data] [data]10500[/data] [data]500[/data] [/row]
[row] [data]Jolt[/data] [data]0[/data] [data]500[/data] [data]0[/data] [/row]
[/tabular]


you can also use colspan and rowspan on data and head if you want to

[data colspan=2] foo [/data]

Examples
The types 6 to 9 have transparent background.
This is from default theme, classic have different colors.

  • Type 1
  • Type 2
  • Type 3
  • Type 4
  • Type 5
  • Type 6
  • Type 7
  • Type 8
  • Type 9
  • Example with caption

Bugs

I have been unable to use require_children and require_parents in the code, so if you type [row], [head] and [data] at the wrong place it can look ugly

AzaToth

I hope you all like this mod. Sorry for beeing unable to use require children/parent, but it just breaks then :(

If there is some enchantments you would like, pleas speak out now.  :P

Do you like the colors? Do you like the styles?

When typing a tabular, you are not required to have a header row, but it's optimal if you have one, because the script first calculate the number of collumns after the count of header cells, and if it wasn't possible it just take the number of cells and divides it with the number of rows.

/Carl

Uzbekistan

And if you code examples also matched pictures... :)
Anyway - great mod! Will definitely add it when SMF final released.
Can you also give a picture example with table cation? Can't see any here.

AzaToth

Quote from: Uzbek on October 10, 2005, 12:18:14 AM
And if you code examples also matched pictures... :)
Anyway - great mod! Will definitely add it when SMF final released.
Can you also give a picture example with table cation? Can't see any here.
done...

Example with caption here also:
[tabular type=4 caption="[b]Table 1:[/b] My budget this month (in dollars)"]
[row] [head]Type[/head] [head]In[/head] [head]Out[/head] [head]Sum[/head] [/row]
[row] [data]Payment[/data] [data]4000[/data] [data]0[/data] [data]4000[/data] [/row]
[row] [data]Food[/data] [data]0[/data] [data]3000[/data] [data]1000[/data] [/row]
[row] [data][red]Mama[/red][/data] [data]10000[/data] [data]0[/data] [data]11000[/data] [/row]
[row] [data]Computer[/data] [data]0[/data] [data]10500[/data] [data]500[/data] [/row]
[row] [data]Jolt[/data] [data]0[/data] [data]500[/data] [data]0[/data] [/row]
[/tabular]


dtm.exe


AzaToth

Quote from: dtm.exe on October 10, 2005, 10:26:27 AM
Nice mod :).
Thank you..

By the way, do you know if I can do this mod without using validate on tabular and row? So I don't use 'type' => 'unparsed_content', because that makes require_parent unusable :(

LostProphecy

Angelus Ex Quo Nox

Ivan Minic


Oldiesmann

Quote from: AzaToth on October 10, 2005, 11:06:15 AM
Quote from: dtm.exe on October 10, 2005, 10:26:27 AM
Nice mod :).
Thank you..

By the way, do you know if I can do this mod without using validate on tabular and row? So I don't use 'type' => 'unparsed_content', because that makes require_parent unusable :(

Try parsed_equals.
Michael Eshom
Christian Metal Fans

AzaToth

Quote from: Oldiesmann on October 12, 2005, 03:17:05 PM
Quote from: AzaToth on October 10, 2005, 11:06:15 AM
Quote from: dtm.exe on October 10, 2005, 10:26:27 AM
Nice mod :).
Thank you..

By the way, do you know if I can do this mod without using validate on tabular and row? So I don't use 'type' => 'unparsed_content', because that makes require_parent unusable :(

Try parsed_equals.
That doesn't work because I don't use any equals, the tag is [tabular type=n caption="text"]...[/tabular]

Oldiesmann

Wasn't thinking about that... Sorry...

What happens if you use required_parents for the row, head and data tags (since those are "parsed content" type tags)?
Michael Eshom
Christian Metal Fans

AzaToth

Quote from: Oldiesmann on October 12, 2005, 04:03:01 PM
Wasn't thinking about that... Sorry...

What happens if you use required_parents for the row, head and data tags (since those are "parsed content" type tags)?
Then that tag won't be parsed because it think it has no parent (tabular and row call parse_bbc by them self)

stormlifter

My tabular doesn't seem to be rendering at all.
I have the mod installed through the forum packages section and I copy/pasted your code example to make sure it wasn't my fault and my forum renders the code as if it wasn't enhanced by tabular... No styles are used, it's just the former system.

Does tabular have browser dependancies?

I'll check back here around 8pm ESTern time to see if there is a proposed solution or if you guys want me to post any more information.

The mod looks pretty awesome!

AzaToth

Quote from: stormlifter on October 13, 2005, 01:58:48 PM
My tabular doesn't seem to be rendering at all.
I have the mod installed through the forum packages section and I copy/pasted your code example to make sure it wasn't my fault and my forum renders the code as if it wasn't enhanced by tabular... No styles are used, it's just the former system.

Does tabular have browser dependancies?

I'll check back here around 8pm ESTern time to see if there is a proposed solution or if you guys want me to post any more information.

The mod looks pretty awesome!
First, there are only styles for default and classic, if you are using a custom theme, then you have to copy (and/or change if you want a style that match your theme) the css code to your specified theme.
Second, if you are using default or classic, try to force reload the page (Ctrl-Shift-R on Firefox), sometimes the css don't get updated when the stylesheet is changed, without the styles defined in css, they will look just like an ordinary table.

the code for css is here if you don't want to lookup the code:
/* Tabular by AzaToth */

/* Main tabular layout, must be same for all */
table.tabular1,
table.tabular2,
table.tabular3,
table.tabular4,
table.tabular5,
table.tabular6,
table.tabular7,
table.tabular8,
table.tabular9
{
margin: 1em;
width: 50%; /* Half screen ok? */
max-width: 1024px;
min-width: 600px;
border-collapse: collapse;
empty-cells: show;
}

/* Standard border */
table.tabular1 tr,
table.tabular2 tr,
table.tabular3 tr,
table.tabular4 tr,
table.tabular5 tr,
table.tabular1 colgroup col,
table.tabular2 colgroup col,
table.tabular3 colgroup col,
table.tabular4 colgroup col,
table.tabular5 colgroup col
{
border: 1px solid black;
}

/* Standard padding */
table.tabular1 td,
table.tabular1 th,
table.tabular2 td,
table.tabular2 th,
table.tabular3 td,
table.tabular3 th,
table.tabular4 td,
table.tabular4 th,
table.tabular5 td,
table.tabular5 th,
table.tabular6 td,
table.tabular6 th,
table.tabular7 td,
table.tabular7 th,
table.tabular8 td,
table.tabular8 th,
table.tabular9 td,
table.tabular9 th
{
padding: 0.2em;
}

/* Standard header */
table.tabular1 th,
table.tabular2 th,
table.tabular3 th,
table.tabular4 th,
table.tabular5 th
{
text-align: left;
background: #6b8eae;
color: white;
}

/* Standard caption */
.tabular1 caption,
.tabular2 caption,
.tabular3 caption,
.tabular4 caption,
.tabular5 caption,
.tabular6 caption,
.tabular7 caption,
.tabular8 caption,
.tabular9 caption
{
caption-side: bottom;
font-size: 0.7em;
}


/* Tabular stype 1 */
table.tabular1 colgroup col.tabular_col0 {background: #efefef;}
table.tabular1 colgroup col.tabular_col1 {background: #dedede;}

/* Tabular stype 2 */
table.tabular2 tr.tabular_row0 {background: #efefef;}
table.tabular2 tr.tabular_row1 {background: #dedede;}

/* Tabular stype 3 */
table.tabular3 td {background: #efefef;}
table.tabular3 tr td:first-child {background: #dedede;}

/* Tabular stype 4 */
table.tabular4 tr.tabular_row0 {background: #efefef;}
table.tabular4 tr.tabular_row1 {background: #dedede;}
table.tabular4 tr.tabular_row0 td:first-child {background: #cdcdcd;}
table.tabular4 tr.tabular_row1 td:first-child {background: #bcbcbc;}

/* Tabular stype 5 */
table.tabular5 colgroup col.tabular_col0 {background: #efefef;}
table.tabular5 colgroup col.tabular_col1 {background: #efefef;}


/* Tabular stype 6 */
table.tabular6 th {text-align: left;}
table.tabular6 colgroup col {border-left: 1px solid black;}
table.tabular6 colgroup col:first-child {border-left: 0px;}
table.tabular6 tr {border-top: 1px solid black;}
table.tabular6 tr:first-child {border-top: 0px;}

/* Tabular stype 7 */
table.tabular7 th {text-align: left;}
table.tabular7 colgroup col {border: 1px solid black;}
table.tabular7 tr {border: 1px solid black;}

/* Tabular stype 8 */
table.tabular8 th {text-align: left;}
table.tabular8 colgroup col:first-child {border-right: 1px solid black;}
table.tabular8 tr:first-child {border-bottom: 1px solid black;}

/* Tabular stype 9 */
table.tabular9 th {text-align: left;}

Oldiesmann

It won't work for me either. When I try to install it I see this:

Installations actions for "Tabular":

Installing this package will perform the following actions:
      Type                Action       Description
1.    Execute Modification    install.xml    Modification parse error
2.    Execute Modification    -    Modification parse error
Michael Eshom
Christian Metal Fans

AzaToth

Quote from: Oldiesmann on October 14, 2005, 10:09:58 AM
It won't work for me either. When I try to install it I see this:

Installations actions for "Tabular":

Installing this package will perform the following actions:
      Type                Action       Description
1.    Execute Modification    install.xml    Modification parse error
2.    Execute Modification    -    Modification parse error
tried to install in on clean forum 1.1 RC1?

Xarcell

I've installed this on 2 different sites with no errors and eveything seems to be working great.

One site is 1.1b3 upgraded to rc1 and the other is 1.0.3 upgraded to rc1 and no problems.

This is a must have mod for me. Thanx alot for your hard work on it.

-Xarcell

Oldiesmann

Quote from: AzaToth on October 14, 2005, 11:32:45 AM
Quote from: Oldiesmann on October 14, 2005, 10:09:58 AM
It won't work for me either. When I try to install it I see this:

Installations actions for "Tabular":

Installing this package will perform the following actions:
      Type                Action       Description
1.    Execute Modification    install.xml    Modification parse error
2.    Execute Modification    -    Modification parse error
tried to install in on clean forum 1.1 RC1?

Yes. No mods, no custom themes, just a standard 1.1RC1 install
Michael Eshom
Christian Metal Fans

AzaToth

Quote from: Oldiesmann on October 24, 2005, 01:09:39 PM
Quote from: AzaToth on October 14, 2005, 11:32:45 AM
Quote from: Oldiesmann on October 14, 2005, 10:09:58 AM
It won't work for me either. When I try to install it I see this:

Installations actions for "Tabular":

Installing this package will perform the following actions:
      Type                Action       Description
1.    Execute Modification    install.xml    Modification parse error
2.    Execute Modification    -    Modification parse error
tried to install in on clean forum 1.1 RC1?

Yes. No mods, no custom themes, just a standard 1.1RC1 install
thats rather strange   ???
are you sure you have write permissions? I think I can recall that simlar errors can appear if you don't have write permissions
chmod og+w -R *

stormlifter

Thanks AzaTroth

Your a winner!

Advertisement: