• Welcome to Simple Machines Community Forum. Please login or sign up.
December 05, 2021, 12:47:53 AM

News:

SMF 2.0.18 has been released! Please update. Read more.


Table From CSV

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

Previous topic - Next topic

Anguz

October 27, 2004, 06:34:53 AM Last Edit: August 21, 2007, 02:23:33 AM by Anguz
Link to Mod

This mod adds a new tag that'll create a table from CSV text. This is, by far, the simplest way of creating table. Each line is a row (if there's more than one, the first will be the headers). Values are separated by the separator specified in the tag using this format [table=,] (no value [table=] will default to ","). The resulting table can be sorted by clicking on the column headers.

Copyright 2007 by Cristian Lavaque. http://anguz.net
sorttable.js copyright 2003 by Stuart Langridge. http://www.kryogenix.org
Cristián Lávaque http://cristianlavaque.com

Anguz

October 27, 2004, 02:33:53 PM #1 Last Edit: October 27, 2004, 02:38:54 PM by Anguz
Here's a simple example:


[table=]Num,Name,City
456,John,N.Y.
123,Charles,L.A.
789,Peter,D.C.[/table]


Attachment 1 is how it it comes out and 2 after sorting it by Name clicking on the column header. ;)

Of course, you can style it in your CSS file, the class is .sortable.
Cristián Lávaque http://cristianlavaque.com

Tristan Perry

Nice job  :) It looks really helpful!

Grudge

Yea, I think it's a very cool idea actually.
I'm only a half geek really...

Omar Bazavilvazo

October 27, 2004, 06:32:33 PM #4 Last Edit: October 27, 2004, 06:36:57 PM by Omar Bazavilvazo
I like it a lot: simple and useful!




Personal Signature:
HablaJapones
http://hablajapones.org
http://hablajapones.org/tutoriales.php


NO me manden PM para soporte o dudas
...Leo los foros como todos...

codenaught

Very nice mod! A simple mod that can be very handy! I really like it.  :)
Dev Consultant
Former SMF Doc Coordinator

Ben_S

Will probably install this one :). Nice idea.
Liverpool FC Forum with 14 million+ posts.

Anguz

October 27, 2004, 07:58:53 PM #7 Last Edit: October 27, 2004, 08:05:00 PM by Anguz
Hey all, thank you for the comments! I'm really glad you find it useful. :D

I'll probably add alternating backgrounds (optional of course, modifying the styles) tonight. Will also move it in parsecode and place it before the br tag, so you can use the latter in the values, that'll let you have multiple lines in a cell if so desired.

A clarification on the separators use. Anything between the = and ] will be used as the separator, that includes tabs (just tested to make sure), which is good for tab separated CSV files. You'll need to copy/paste the tab from a text editor though, cause hitting tab in the post form will move the focus to the next element in the form. If it's left blank, it'll default to a comma.

One more thing, it's a nice short-hand to create tables in messages and it's way faster than the current table parsing, even the one in FasterParsecode, so you may prefer to use it when possible.
Cristián Lávaque http://cristianlavaque.com

Anguz

October 28, 2004, 06:49:50 AM #8 Last Edit: October 29, 2004, 04:32:31 AM by Anguz
Updated to 1.10

Didn't do the br tag thing because it gave some trouble and I didn't consider it that important to bother making it work. If you need multiple lines in a cell, just use the normal table tag. :)

The alternating row backgrounds are in there now. Thanks to [Unknown] for his help with JS. I'm attaching a new screenshot. ;)

I also added some simple styling, as you can see, which you can easily modify if you don't like.
Cristián Lávaque http://cristianlavaque.com

jacbier

Hello Anguz,

Thank you for this simple en useful mod.

Jacques

Anguz

I'm glad you liked it! Thank you for writting! :D
Cristián Lávaque http://cristianlavaque.com

Oldiesmann

Michael Eshom
Cincy Space - now open!

codenaught

I am having a problem with this mod. When I add a link to a row, first the link won't auto wrap a [ url ] tag around it like the links do on this forum when just typing in a link. For example typing in http://www.google.com without the [ url ] tags will still make it clickable. And also when I do wrap the [ url ] [ /url ] tags around it the link will turn out all wrong.

So for example if I do this,


[table=]test,test,test
test,test,[url]http://www.google.com[/url][/table]


the page that shows up when clicking that link is:

http://www.myaddress.com/myforumdirectory/%5C%22http://www.google.com%5C%22

of course where myaddress and myforumdirectory were used instead of my real one.

any ideas how to fix it so you can use links in the tables?

PS: If it helps, when hovering the link at the bottom the link appears to be going to: http://www.myaddress.com/myforumdirectory/\"http://www.google.com\"
Dev Consultant
Former SMF Doc Coordinator

Anguz

I haven't tried using tags in the CSV table. I'll try it out in my test server and see what I can find out.
Cristián Lávaque http://cristianlavaque.com

Anguz

I fixed it parsing the CVS table before the other tags. Links are working now, look at the status bar in the screenshot. I'll post an update in a moment.
Cristián Lávaque http://cristianlavaque.com

codenaught

Okay thanks. Great mod may I say again. It is a very nice simple way to arrange things in order. Keep up with the nice bbcodes.  ;D
Dev Consultant
Former SMF Doc Coordinator

Anguz

Updated to 1.11


  • Links, and probably other bbcode tags, weren't working inside the table.
  • You can now also use the br tag which will let you do multilines inside a value.
Cristián Lávaque http://cristianlavaque.com

Elijah Bliss

Do I have to add anything in order to make the tables sortable because their are no links showing up to sort them as shown in your screen capture.

Aside from that, great mod.

Anguz

There's a javascript file added to your default theme dir during install. If you're using another theme, you need to make a copy of the file to that theme's dir as well.
Cristián Lávaque http://cristianlavaque.com

Elijah Bliss

Quote from: Anguz on December 05, 2004, 06:20:46 PM
There's a javascript file added to your default theme dir during install. If you're using another theme, you need to make a copy of the file to that theme's dir as well.

The "sorttable.js" is located in the theme I am using.

The problem I am encountering is this:
if I just have this for example:
[table=]Giants,Forty Niners,Bears[/table]

the sortable links show up in the headers, but as soon as I make a carriage return,
[table=]Giants,Forty Niners,Bears
Bonds,Young,Arrington[/table]

the links in the headers go dead.

Advertisement: