Table From CSV

Started by Anguz, October 27, 2004, 06:34:53 AM

Previous topic - Next topic

LeYoyo

Still no SMF v2.0 version available ?
Sous SMF 2.0.8

abraamz

#221
I have manually added this mod to smf 2.0.2 succesfully with the instructions in the message linked below
http://www.simplemachines.org/community/index.php?topic=18917.msg2412038#msg2412038
It is located in the previous page.

I had to search in the index.template.php for this code
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
and add the mods code below that line like this:
<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sorttable.js"></script>
you have to upload the sorttable.js file to Themes/default/scripts

edit***
i found some errors. you have to add a description for the new button if you choose to make one to use with [csv=|]
Quote from: ianus on December 19, 2009, 11:34:53 AM

Open: Sources/Subs-Editor.php
Find: // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!

Choose where your button should appear and add
array(
'image' => 'csv',
'code' => 'csv',
'before' => '[csv=|]\n\n',
'after' => '[/csv]',
),




the above code should be
array(
'image' => 'csv',
'code' => 'csv',
'before' => '[csv=|]\n\n',
'after' => '[/csv]',
                                'description' => $txt['csv']
),


and you should add a text entry into file Post.English.php
find this
$txt['table'] = 'Insert Table';

add below this

$txt['csv'] = 'Insert Table from csv';

danielwmoore

#222
This is a mod that has been a HUGE headache saver for me. I frequently do tables, and this makes it easier than any other way I've ever done it.

However, it is a pain to implement on SMF 2 with all the changes and all. I have, therefore, recreated this same mod for SMF 2.0. It's not my code, but I have used the original mod, made the appropriate changes as noted on the last 3 pages of this thread, and placed it into a new XML package for SMF 2.0.

I have installed it on SMF 2.0.6, and it worked flawlessly.

I even added the "button" to insert the CSV table automatically with the posts. I also renamed the tag from 'table' to 'csv', as per ianus's suggestion. Thought that was a good idea.

That means the tag is CSV, not TABLE!

I included both PNG and GIF images for the button, since most people seem to use GIF, but many also have converted to PNG as I have. PNG is much smoother, but in this case it is just a "copy" of the GIF in order for it to work as a PNG on your setup. You can remove whichever one you don't use.

One thing I also did was remove all the CSS changes, as I didn't really see the need of setting up a whole new CSS that really only works with the SMF 1 default theme. The bright backgrounds really clashed on my dark themes on my forum. So instead, it borrows the colors from the standard 'table' bbc tag. All formatting will be like you used the 'table' tags, however your theme displays it.

Arantor

Unfortunately, we can't let you distribute it without permission from the author - it's not given an open source licence and one cannot just be assumed. Sucks but for everyone's safety that's what we have to do :(

danielwmoore

Thanks for the quick reply on that, even if it isn't the news I wanted to hear. Always best to keep it straight.

I have obtained the original author's email address, and will send him an email attaching the mod. Perhaps he will be willing to return and publish it himself. I would have sent a PM, but I'm not sure if he still checks the forums.

If he doesn't return, then the community will have to do without. It certainly is a shame, though, as I think this mod would be ideally suited to be part of the core of SMF itself. It just makes tables too easy.

Arantor

If the original author gets in touch here, or send a PM to the 1 account, we can take it further.

The problem with using a CSV entry is what happens if you want to have a table cell with a , in it. I know the times I've used tables, this has been an issue for me.

If it were core, it would likely get rewritten anyway and the licence problem would go away - I know a better form of table code in the core would be advantageous, especially if it means we can come up with a less insane way of handling the sanitisation aspect (but don't forget, we still have to deal with people upgrading who have the old style tables)

danielwmoore

Quote from: Arantor Beeblebrox the First on December 01, 2013, 08:54:26 PM
The problem with using a CSV entry is what happens if you want to have a table cell with a , in it. I know the times I've used tables, this has been an issue for me.

That's what was so great about this mod. By using [CSV=|], it would use "|" as the delimiter. You can use whatever you want as a delimiter. Of course, a real CSV file would put quotes around an entry that contains a comma, and just not display the quotes. It's a way of allowing commas without a comma being a delimiter. This can't handle quoted entries. Real CSV handling, though, would be a much more complex code base, which would slow things down too much. However, it would enable a user to create a table using Excel or some other spreadsheet, save it as CSV, then paste it into a post. Just a thought, but perhaps I think too much sometimes. :)

It would be nice for it to be smart enough to handle "empty" cells, like:
1,2,3
4,,6
7,8,
10,11,12

But it doesn't. You have to supply something, even if it's just a dash or dot.

Since the tag is CSV=, old style tables can still be used as well. Not a replacement of the core really, but an addition to the core.

tfs

Just an FYI re semantics of separators and delimiters.

CSV = Comma SEPARATED values.  The comma is the separator and the quotes are the delimiters.

A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

danielwmoore

@tfs: I stand corrected. You are right.

Having a rough week, with my 1 year old having bronchitis and on a breathing machine 4 times a day, I haven't slept in days. My brain is more feeble than usual. ;)

tfs

Prayers up for your tyke.  It's very hard to watch a small child suffer through medical troubles.  Best wishes for a full and speedy recovery.
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Advertisement: