How to do tables

salvidor

Registered User
Messages
49
A quick guide to using tables (I have played around with these and do not have any access to documentation, so someone out there might do better).

NOTE: carriage returns (the enter key) are very important each row is a new line.

NOTE: all of the quotes below contain a space between the / and table [/ table] in the closing block so you can see the code - you can copy and paste these examples and just remove the extra space.

Start the line with the table tag and then type the value you wish to appear in the first cell, next use the pipe character (shift + \) and type the value you want to appear in the next cell and so on. Once you do not use enter to go the the next line - these cells will all appear on a single row - note you do not end the line with a pipe. And then end the table block [/ table] - either on the same or next line.

3 columns, 1 row

cell1|cell2|cell3
[/ table]

AND

cell1|cell2|cell3[/ table]


both gives you:
cell1|cell2|cell3
9 columns, 1 row

cell1|cell2|cell3|cell4|cell5|cell6|cell7|cell8|cell9
[/ table]


gives you:
cell1|cell2|cell3|cell4|cell5|cell6|cell7|cell8|cell9

WRONG: if you have the table tag on one line and the cell text on the next line like this:

incorrect format - give 1 column, 1 row


cell1|cell2|cell3
[/ table]



you get:


cell1|cell2|cell3

This is because the first line with the table tag determines the number of columns the table will have - since there is nothing except the table tag on this line only a single column is generated.



Now we know how to create a single row of data - adding new rows is very simple - after you have defined the amount of columns you want (the first line) - just hit the enter key and enter a new row - there should be the same number of cells in each row.

3 columns, 3 rows

cellA1|cellA2|cellA3
cellB1|cellB2|cellB3
cellC1|cellC2|cellC3
[/ table]


gives you:
cellA1|cellA2|cellA3
cellB1|cellB2|cellB3
cellC1|cellC2|cellC3
3 columns, 5 rows

cellA1|cellA2|cellA3
cellB1|cellB2|cellB3
cellC1|cellC2|cellC3
cellD1|cellD2|cellD3
cellE1|cellE2|cellE3
[/ table]


gives you:
cellA1|cellA2|cellA3
cellB1|cellB2|cellB3
cellC1|cellC2|cellC3
cellD1|cellD2|cellD3
cellE1|cellE2|cellE3

Each table row that is produced alternated in colour so you can distinguish the rows - but what if you want to add a proper looking header to your table?

This is achieved by placing ="head" in the opening table tag, like so:

3 columns, 5 rows - with headers

[table="head"]Heading1|Heading2|Heading3
cellA1|cellA2|cellA3
cellB1|cellB2|cellB3
cellC1|cellC2|cellC3
cellD1|cellD2|cellD3
cellE1|cellE2|cellE3
[/ table]

gives you:
Heading1|Heading2|Heading3
cellA1|cellA2|cellA3
cellB1|cellB2|cellB3
cellC1|cellC2|cellC3
cellD1|cellD2|cellD3
cellE1|cellE2|cellE3


If you need to leave cells blank you just omit the text you would have put in and always remember the | (pipes) and carriage returns must remain.

Say I want to have a table which compares a car and a bike against having wheels, engine and pedals - I want to have car and bile on the Y and Wheels, Engine and Pedals on the X - firstly I need to have an empty cell in the top left.

To do this we just omit the text for this cell but keep the pipe.


Empty cells example

|Wheels?|Engine?|Pedals?
Car|X|X|
BIke|X| |X
[/ table]


gives you:
|Wheels?|Engine?|Pedals?
Car|X|X|
BIke|X| |X
In the following examples you will need to look closely to see the empty cells
Notice the first line after the table tag has an empty space before the first | - this tells the table to define 3 columns and leave the first empty:
|Wheels?|Engine?|Pedals?
|Wheels?|Engine?|Pedals?

The second line - the car has a trailing pipe with a blank space after it - this tells the table to leave that cell empty
Car|X|X|

The third line has an empty space between the pipes which tells the table to leave the 3rd cell of this row empty.
BIke|X| |X
BIke|X| |X

I hope that you have found this useful and I have updated a post: www dot askaboutmoney dot com/showpost.php?p=1006396&postcount=5 for you to have a look at how it might be used.

If you have any questions, comments or issues post here and Ill answer to the best of my ability.


NOTE: I have written this based on playing with the tags, with no access to documentation as I do not have an account to access info here: www dot vbulletin dot org/forum/showthread.php?t=107985

Happy tabling!
 
Re: How to use tables

Salvidor

That is brilliant. Thanks very much. I will play with it later.

By the way, you should be able to post links now that you have 10 posts.

I have pasted the content of the other thread in case it adds anything. Though I think you have covered everything:

BB Code
by StGaensler
Description
This Hack provides a BB code
to add a table to the post
The skin of the table automatically fits the style because the CSS classes of vBulletin are used.

A table is simply made of some lines (will be the rows). The cols are seperated by | . So this will be a table:

Block Disabled: ( Update License Status ) Suspended or Unlicensed Members Cannot View Code.
A screenshot of a "ready" table is attached

Usage
  1. install attached product XML through product manager (overwrite existing)
  2. install at least one language pack in AdminCP -> Languages & Phrases -> Download / Upload Languages -> Import Language XML File
    Important: Select the language you want to import the phrases into, not "(Create New Language)" - this won't work! If you use another version of vBulletin than I use enable "Ignore Language Version" to import the language pack.
Please note: (installing)
Installing this product will: (reverted during uninstall)
  1. rename a existing BB code "table" to "table_saved"
  2. add a new BB code

If you want to have live sortable columns (JavaScript): Download attached sorttable.js.txt rename it to sorttable.js and place it into the /clientscript/ folder of your vBulletin. Then go to AdminCP -> vBulletin Options -> BB Code
Settings -> Enabled Features Of This BB Code
and enable sortable
Note: Including the file on the webpages where it is necessary is done by my product. So if sortable is disabled, it won't be included automatically.
If you want to have a icon for the editor you may use this for free:
table.gif
Download this icon and place it in your /images/editor/ folder.

Please note: (usage)
  • Of course you can use vB Code and smilies inside the table!
  • The first line defines how much columns are in the table. If the other lines have more or less colums they are cut off or filled with   (space)
  • You can find a detailed description of the options (please read it before requesting help)
  • Empty rows are (should be
    wink.gif
    ) removed.
New features
  • define colspan of cells
  • small panel in AdminCP
  • define CSS class of table and tablerows
  • live sorting of table through clicking the head of a column
  • defining maximum width of a table
Maybe planned features
  • detailed description of the vB Code in misc.php?do=bbcode depending on the features enabled in AdminCP (planned for next beta version)
  • define formatting (bold, italic), align (left, right, center) and width of the cols
Suggested but not planned features
  • none
Known problems
  • Bugfix of version 0.1.1 doesn't work if vBulletin should write template names into the source code
Version history:
0.0.1 - 0.0.5 internal releases for testing purposes (Thanks to Zombie79 from [broken link removed] for testing)
0.1 first official release
0.1.1 fixed small bug: if a line ends with eg vbcode quote no new row was generated (should already have been fixed but did not work)
0.1.2 workaround: removed call to function bcmod(), it could also be done another way
smile.gif

0.1.3.x beta version described here (and following) - added admin panel, colpan and css feature
0.1.4 stable version - no significant changes to the last beta (0.1.3.8)
0.1.5.x beta version described here (and following) - added sortable, maxwidth, versioncheck, upgrade message, compatibility to vB 3.6
0.1.6 stable version - two bugfixes to last beta, {br} for posting linebreaks in a tablecell
0.1.7.x stable version - compatibility to vB 3.7 ( description ) - added tab seperated tables

This hack can be used for free. If you want to make a small donation, just contact me. We will find a way
smile.gif

I don't want this product to be distributed from other sources. Please don't upload it to other vBulletin related boards etc.
 
Re: How to use tables

No problem!

1 post left before I hit 15 to post links!

Thanks
 
Last edited:
Re: How to use tables

Salvidor

I have had a bit more time to go through this and you really wrote it well.

You even anticipated my errors in practice:

WRONG: if you have the table tag on one line and the cell text on the next line like this:

The examples are really good.
 
Re: How to use tables

drugs|drink|gambling
drugs|drink|gambling
10||20

OK, so it's head , not "head"

drugs|drink|gambling
10||20

20|30|40

|drugs|drink|gambling
women:|10||20

men:|20|30|40


|drugs|drink|gambling|other addictions
women:|10||20|5

men:|20|30|40|80



|drugs|drink|gambling|other
addictions
women:|10||20|5

men:|20|30|40|80

I tried to get Other Addictions onto two lines in the one cell and it doesn't work. Even with shift and enter.
 
Re: How to use tables

If you want to learn tables

1) Do a simple example
2) Hit Submit Reply to see what it looks like
3) Edit the post
4) Copy the text and paste it again within the same post
5) Edit the second version to add something else e.g. head
6) Hit Submit Reply to see the impact of that.
 
Re: How to use tables

|drugs|drink|gambling|other addictions
women:|10||20|5
men:|20|30|40|80

|drugs|drink|gambling|other
addictions
women:|10||20|5
men:|20|30|40|80
I tried to get Other Addictions onto two lines in the one cell and it doesn't work. Even with shift and enter.

In order to break the text over two lines in a cell you can use {br} where you want the line break to appear - however, this doesnt appear to work if the table is marked to have a header:
[table=head]|drugs|drink|gambling|other{br}addictions
women:|10||20|5
men:|20|30|40|80[/ table]
|drugs|drink|gambling|other{br}addictions
women:|10||20|5
men:|20|30|40|80

|drugs|drink|gambling|other{br}addictions
women:|10||20|5
men:|20|30|40|80[/ table]

NOTE: no =head
|drugs|drink|gambling|other{br}addictions
women:|10||20|5
men:|20|30|40|80

So for examples like the one above it appears not to be suitible, but for an example like the below - it works well.

From Brendans post
Private residential{br} mortgages: |793,000||€118 billion
Average mortgage: |€150,000||
Number in arrears {br}over 90 - 180 days:| 9,418 |1%|€1.7billion
Number over {br}180 days: |19,185 |2.5%|€3.6 billion
[/ table]
Private residential{br} mortgages: |793,000||€118 billion
Average mortgage: |€150,000||
Number in arrears {br}over 90 - 180 days:| 9,418 |1%|€1.7billion
Number over {br}180 days: |19,185 |2.5%|€3.6 billion
Legal action
Court proceedings outstanding : |3,200
Repossessions: |27
Voluntary surrender or abandonment: |74[/ table]
Court proceedings{br} outstanding : |3,200
Repossessions: |27
Voluntary surrender {br}or abandonment: |74

You can use as many breaks as you like in a cell.

this{br}is{br}a{br}single{br}cell{br}with{br}multiple{br}breaks|no break here
[/ table]
this{br}is{br}a{br}single{br}cell{br}with{br}multiple{br}breaks|no break here

As above: NOTE: all of the quotes below contain a space between the / and table [/ table] in the closing block so you can see the code - you can copy and paste these examples and just remove the extra space.
 
Re: How to use tables

I think the examples shown are seriously flawed.

Who would believe that no women are addicted to drink? :)
 
Re: How to use tables

What are tables. What are they for... Why would you use them, and for what. Are we all missing something?
 
Re: How to use tables

What are tables. What are they for... Why would you use them, and for what. Are we all missing something?
Hi lyonsie,

It is just for presentation really...

Say you wanted to present a table of data to show something like the Break down of Principle & Interest over the term of a loan - these dont present well by default:

Break down of P&I


YR Intrest Principal Balance
2010 $12,698.07 $9,329.32 $390,670.68
2011 $13,505.71 $10,524.17 $380,146.51
2012 $13,131.39 $10,898.49 $369,248.02
2013 $12,743.77 $11,286.11 $357,961.91
2014 $12,342.36 $11,687.52 $346,274.39
2015 $11,926.69 $12,103.19 $334,171.20

The above is not very readable, so you can use a table to present the same data in a far more readable format:

Break down of P&I


YR| Intrest| Principal| Balance
2010| $12,698.07| $9,329.32| $390,670.68
2011| $13,505.71| $10,524.17| $380,146.51
2012| $13,131.39| $10,898.49| $369,248.02
2013| $12,743.77| $11,286.11| $357,961.91
2014| $12,342.36| $11,687.52| $346,274.39
2015| $11,926.69| $12,103.19| $334,171.20

Thats all really - its just so you can present data better. See this thread for a real world example.
 
Re: How to use tables

What are tables. What are they for... Why would you use them, and for what. Are we all missing something?

The Best Buy Tables could well be reformatted into real tables.

It took me ages to read the Financial Regulator's press release on arrears.

Putting it into the table above makes it readable.

Brendan
 
Hi Cashier

The table tag is just an opening table tag [ table] followed by your columns and then a closing table tag [ /table] at the end of your table. (Type these without the spaces)

The columns are divided by pipes which are just |||. These pipes are found by holding down shift and the backslash key.

So:

|2011|2012
Sales:|1000|2000
Profit:|500|600 [ /table]

If you type the above exactly except don't leave a space after the opening bracket and the forward slash for the closing tag. I just left this so that it wouldn't convert to a table.

You should then get the following:

|2011|2012
Sales:|1000|2000
Profit:|500|600

Use preview post to check it.

Marion
 
Hi cashier

Great.

So you could see that the opening tag with
just gave me a dark blue header row.

I could have just had a regular row by typing


I have decided that I don't want a dark blue header in my next table.

Marion
 
Sometimes it is not possible to have a header row and word wrap in a column at the same time.

So:



|2011|2012|Average {br} over two years
Sales: |1000 |2000|1500
Profit: |500|600|550[ /table]





Cashier you might indulge me by checking if it works for you. Thanks.

|2011|2012|Average {br} over two years
Sales: |1000 |2000|1500
Profit: |500|600|550


If I didn't have word wrap {br} my table would look like this:

|2011|2012 |Average over two years
Sales: |1000|2000|1500
Profit|500|600|550

Marion

PS: {br} just means break row or word wrap so that my column is not too long.
 
How do I get the total amount?

It doesn't do totals like Excel. You have to work them out manually.

Marion

Thanks for that lesson.

I had not known about word wrap {br} which will be very helpful to me|100
Nor had I known about the heading {br} which I will try as well|200

Brendan
 
Back
Top