News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Tabular

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

Previous topic - Next topic

@ngel

Is it possible to add a parameter to set the width for each "HEAD" in place of make a calculation using the number of column.

Thanks

menzagitat

I guess nobody will help us, support for this mod seems to be discontinued  :-\

@ngel

Hi,

After many test to understand the use of "preg_match_all", I added a width parameter to TABULAR.

So need to change 2 places in Subs.Php :

First Search
/* This is the validation code for tabular, typed here because it's present at three
And replace $tabular_validation with
/* This is the validation code for tabular, typed here because it's present at three different locations */
$tabular_validation = create_function('&$tag, &$data, $disabled','
// retrieve row tag and contents like head, data
preg_match(\'#\[row\](.*?)\[\/row\]#is\', $data, $matches);
// count the number of "head" tag without any parameters
$tabular_cols = preg_match_all(\'#\[head\]#is\',$matches[0],$null);
// count the number of "head " tag (for parameter : colspan, rowspan and width)
$tabular_colwidths = preg_match_all("#head ([^\]]+)#is",$matches[0],$headdata);
// check if there, at least, one "head "
if ($tabular_colwidths > 0) {
// at least, one "head " so initialize the tag colgroup
$colgroup = "";
// count the number of "width=xx" (without %) in the "head " tag
$tabular_colwidths = preg_match_all("#width=(\d+)#is",$matches[0],$headdata);
// no need to test, loop will do it
for ($i=0;$i<$tabular_colwidths;$i++) {
// determine the type of tabular
$mod = $i%2;
// check the column position, because no need to set a width for lastest column (except if only one column)
if (($i == ($tabular_colwidths-1)) && ($tabular_colwidths !=1)) {
$colgroup .= "<col class=\"tabular_col$mod\"/>";
} else {
$colgroup .= "<col class=\"tabular_col$mod\" width=\"".$headdata[1][$i]."%\"/>";
}
}
} else {
if($tabular_cols == 0) {
/* We do not have a header, lets do a lousy hack */
$tabular_rows = preg_match_all(\'#\[row\]#is\',$data,$null);
$tabular_cells = preg_match_all(\'#\[data\]#is\',$data,$null);
$tabular_cols = ceil($tabular_cells / $tabular_rows);
}
$colgroup = "";
for($i = 0; $i < $tabular_cols; $i++) {
$mod = $i%2;
$colgroup .= "<col class=\"tabular_col$mod\" width=\"".(100/$tabular_cols)."%\"/>";
}
}
$colgroup = "<colgroup>".$colgroup."</colgroup>";
$data = $colgroup.parse_bbc($data);
');


Second Search
'tag' => 'head',
'parameters' => array(
'colspan' => array( 'match' => '(\d+)', 'optional' => true, 'value' => ' colspan="$1"'),
'rowspan' => array( 'match' => '(\d+)', 'optional' => true, 'value' => ' rowspan="$1"'),

And replace with
'tag' => 'head',
'parameters' => array(
'colspan' => array( 'match' => '(\d+)', 'optional' => true, 'value' => ' colspan="$1"'),
'rowspan' => array( 'match' => '(\d+)', 'optional' => true, 'value' => ' rowspan="$1"'),
'width' => array( 'match' => '(\d+)', 'optional' => true, 'value' => ' width="$1"'),


Now, you can use the following statement for the HEADer
[head width=10]Col 1[/head]
[head width=25]Col 2[/head]
[head width=65]Col 3[/head]


For the lastest Col, you can set any value because the value is calculated directly.

Ciinien

I've tried several times to install Tabular on my SMF 1.1.1/TP0.9.7 site and keep getting the following message. Anyone overcome this that might could tell me how to do so?

*************************************
Install Actions
Installations actions for "Tabular":
The package you are trying to download or install is either corrupt or not compatible with this version of SMF.
*************************************

Thanks in advance for any help and/or advice.
LotRO  Info Central

"Never try to teach a pig to sing. It just annoys the pig and frustrates you. " -- an old saying

AzaToth

Quote from: menzagitat on January 24, 2007, 09:07:22 PM
I guess nobody will help us, support for this mod seems to be discontinued  :-\

not "Discontinued", have just been busy with other things. please refresh my mind with things in need of fixing, and I'll look into it.

/Carl

AzaToth

have released a bumped version for 1.1.2, nothing is "changed" just the version number

rockinaway

Is there any way buttons can be added to posts form, like the bold and italic buttons.. so users can click those to create a table?
Have I helped you? Then please join AdminFuel - The forum for forum administrators.

If you need help managing your forum, or maybe launching it, then visit us and view the quality articles, downloads and posts.

WifiGamer

I'm having issues with this mod displaying correctly in IE.
It displays just fine in Firefox but in IE it doesn't look right.

kaladorn

1. Awesome mod. My site has a lot of tabular data and this *really* helps. The fact that you have implemented colspan and rowspan is also much appreciated!
2. If I was to ask for things, here is my list:
  a) Width specification for columns (I see someone has hacked it in a few posts before this one, perhaps you can integrate that)
  b) Location specification for caption (above/below)
  c) Text alignment (vertical and horizontal) within cells
   
I manually ported over the CSS styles to Moonraker theme and things worked like a charm (some colour tinkering required, but that's easy stuff).

This is one of the best mods (along with displaying attachments inline in mid-post) available for SMF.

Edvard

Hi! I didn't get it to work on 1.1.4. I got an error about the file not containing any installation actions to be undertaken (translated from Norwegian). Any chance of getting an updated version or do I have to 'hack' my way into it myself?

falguni1


franklinrony

great my friend very usefull
http://twitter.com/franklinrony

Entra y aprende a ser un webmaster
www.sv-blog.com
--Si pides ayuda al menos agradece el soporte recibido----

Rasyr

Is this mod going to be updated for SMF 1.1.7??

Mexx-uk

Any chance this mod will be updated for 1.1.10??? This is an excellent mod that I really could use in my forum!  ;D

Meares

It's working fine with 1.1.11, so I think it'll be fine with 1.1.10 too.
Anything that you must do, is unpacking archive and editing package-info.xml:
<?xml version="1.1"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">

<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<id>azatoth:tabular</id>
<name>Tabular</name>
<version>0.2.1</version>
<type>modification</type>
<install for="1.1,1.1.2,XXX">
<readme>README</readme>
<modification>install.xml</modification>
</install>
<uninstall for="1.1,1.1.2,XXX">
<modification reverse="true">install.xml</modification>
</uninstall>
</package-info>

Where XXX is your SMF version.

If you're using non-default theme on your forum, you'll need to edit yours theme style.css file (you can do this from Administration Center->Configuration->Themes and Layout->Modify Themes->YourTheme->style.css), and add these lines into it's end:
/* 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: #6e94b7;
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: #bfcfdf;}
table.tabular1 colgroup col.tabular_col1 {background: #cfdfef;}

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

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

/* Tabular stype 4 */
table.tabular4 tr.tabular_row0 {background: #bfcfdf;}
table.tabular4 tr.tabular_row1 {background: #cfdfef;}
table.tabular4 tr.tabular_row0 td:first-child {background: #9fafcf;}
table.tabular4 tr.tabular_row1 td:first-child {background: #afbfdf;}

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


/* 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;}

NO CARRIER

Sorry for bumping such old topic, but is it any chances to see this wonderful mod working with version 2.0.x?

Arantor

Seeing that the author has not been here for over 5 years, the answer seems not.

Advertisement: