News:

Wondering if this will always be free?  See why free is better.

Main Menu

Tables - How do I get them to have a border?

Started by Druadan, March 04, 2008, 01:01:55 PM

Previous topic - Next topic

Druadan

I've checked the local help section of the board but there's no details about how to get a table to display a border.  Without the border, tables just look a mess.

I tried adding border=1 to the table tag but that invalidated the tag.

Anyone know how to achieve this?

Thanks

-Dru

capabmx

border=1px?? What tables are you putting borders on, smf tables, or regular html tables? I think youmust specify pixels, unless I am mistaken.
Always looking to take on a web design/ programming job :], PM me if interested.

Druadan

SMF tables, aye.  I know how to do HTML tables, I just can't figure this SMF table out.

capabmx

I believe the tables properties are all in style.css, you can edit it easily from Admin > Themes and Layout > Modify theme. Pick which theme you want to modify, and select it's style.css. Then search for /* By default (td, body..) use verdana in black. */
body, td, th , tr
and you can insert border: solid 1px #d0d0d0;

Specify how wide the border is by setting how many px. Then yuo can change the color of the border by changing the six digit hex color codes.
Always looking to take on a web design/ programming job :], PM me if interested.

Druadan

We either have a misunderstanding or the answer is that there is no way for a user to get borders to show in his tables.




Imeantables
likethisin posts.

capabmx

Oh wow yeah I misunderstood, I apologize. I thought you were talking about editing the tables of the forum. Not user inputted tables. Hmmm, I don't know about that :[, I apologize.
Always looking to take on a web design/ programming job :], PM me if interested.

Druadan

No worries mate.  I can't for life of me figure out how to get this sorted.  I find it hard to believe that it's not possible, especially since no-borders is the worst default option available.  I'd rather have unsightly 10px lime green borders than none at all.

Thanks though.

-Dru

greyknight17

It might require you to use HTML instead:

[html]<table border=1><tr><td>I mean tables</td></tr><tr><td>like this in posts.</td></tr></table>[/html]

This HTML option is only available to administrators by default.

codenaught

Dev Consultant
Former SMF Doc Coordinator

Druadan

Quote from: akabugeyes on March 04, 2008, 06:32:18 PM
This may be able to help you - Bulletin Board Cod.

So I do have to hack it together then.  Thanks.  Not sure I want to do that, given that I was hoping there was a method of freely selecting the type and thickness of border that ordinary members could use too.  Sometimes I'll want a thick border, sometimes a thin border, and sometimes no border.

I'll have to make sure there's adequate padding too so it doesn't look really awful.

Cheers for the help.

-Dru

Rumbaar

Well it now uses the bbc_table class so you can easily define that in your style.css to affect all tables than editing the subs/php each time.

But if you want to design a new BB Code so you can pass attributes to it you might want to look how it's done for say the IMG tag:
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),


Untested, but maybe something like this:
array(
'tag' => 'table',
'parameters' => array(
'border' => array('optional' => true, 'value' => ' border="$1"', 'match' => '(\d+)'),
),
'before' => '<table {border} class="bbc_table">',
'after' => '</table>',
'trim' => 'inside',
'require_children' => array('tr'),
'block_level' => true,
),

The it would hopefully work like [table border=1][tr][td][/td][/tr][/table], etc  I'm sure you could add extra attributes to the defined table BB Code.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Roo

Here's what I ended up using.  You need two table entries, the first one with no parameters, the second one with.  Also, when using the tags, you need to use them in the order listed in the parameters, otherwise they don't work. 

E.g.  [table border=1 cellspacing=0 cellpadding=0 bordercolor=red bgcolor=yellow]

You can leave some out though if you don't want to use them.  E.g. [table border=1 bgcolor=yellow]

            array(
                'tag' => 'table',
                'before' => '<table style="font: inherit; color: inherit;">',
                'after' => '</table>',
                'trim' => 'inside',
                'require_children' => array('tr'),
                'block_level' => true,
            ),
            array(
                'tag' => 'table',
                'type' => 'unparsed_equals',
                'parameters' => array(
                    'border' => array('optional' => true, 'value' => ' border=$1', 'match' => '(\d+)'),
                    'cellspacing' => array('optional' => true, 'value' => ' cellspacing=$1', 'match' => '(\d+)'),
                    'cellpadding' => array('optional' => true, 'value' => ' cellpadding=$1', 'match' => '(\d+)'),
                    'bordercolor' => array('optional' => true),
                    'bgcolor' => array('optional' => true),
                ),
                'before' => '<table{border}{cellspacing}{cellpadding} bordercolor="{bordercolor}" bgcolor="{bgcolor}" style="font: inherit; color: inherit;">',
                'after' => '</table>',
                'trim' => 'inside',
                'require_children' => array('tr'),
                'block_level' => true,
            ),

greyknight17

Druadan, did the above suggestion resolve the issue?

EL34

Quote from: Roo on April 16, 2008, 01:54:44 AM
Here's what I ended up using.  You need two table entries, the first one with no parameters, the second one with.  Also, when using the tags, you need to use them in the order listed in the parameters, otherwise they don't work. 

E.g.  [table border=1 cellspacing=0 cellpadding=0 bordercolor=red bgcolor=yellow]

You can leave some out though if you don't want to use them.  E.g. [table border=1 bgcolor=yellow]

            array(
                'tag' => 'table',
                'before' => '<table style="font: inherit; color: inherit;">',
                'after' => '</table>',
                'trim' => 'inside',
                'require_children' => array('tr'),
                'block_level' => true,
            ),
            array(
                'tag' => 'table',
                'type' => 'unparsed_equals',
                'parameters' => array(
                    'border' => array('optional' => true, 'value' => ' border=$1', 'match' => '(\d+)'),
                    'cellspacing' => array('optional' => true, 'value' => ' cellspacing=$1', 'match' => '(\d+)'),
                    'cellpadding' => array('optional' => true, 'value' => ' cellpadding=$1', 'match' => '(\d+)'),
                    'bordercolor' => array('optional' => true),
                    'bgcolor' => array('optional' => true),
                ),
                'before' => '<table{border}{cellspacing}{cellpadding} bordercolor="{bordercolor}" bgcolor="{bgcolor}" style="font: inherit; color: inherit;">',
                'after' => '</table>',
                'trim' => 'inside',
                'require_children' => array('tr'),
                'block_level' => true,
            ),


I know this is a very old topic
I want to add a 1px border to BBC tables and cells

I am not sure what .css file to modify?

I am using the responsive mod on SMF 2.0.17
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

Irisado

This topic is for version 1.1.x of SMF and it is twelve years old.  Please start a new topic in the appropropriate support board or, if the issue relates to a specific mod, please post in the support topic for that mod.  Topic locked.
Soñando con una playa donde brilla el sol, un arco iris ilumina el cielo, y el mar espejea iridescentemente

Advertisement: