I am *so* in love with all the new things you can do in Drupal!

You can see my table here: http://www.animecards.org/node/66

I used this code to summon it:
<?php print tablemanager_display(2, NULL, TRUE, array ('cellpadding' => '5')); ?>

Things I want to know!

Sorting: I would the default sort to be Series name AND Set name (so that, for example, it would be Bleach CM 1, Bleach CM 2, instead of Bleach CM 1, CM 3, CM 2 like it is now.) Can I do that in PHP?

Permissions: I would also like for all authenticated users to be able to edit any row in the table. Right now they can only edit their own rows. In an ideal world, that would work out fine, but a lot of times I'm the one adding it to begin with; I'd like for them to be able to edit what I have made. Of course they shouldn't muck with other people's rows... Well, either a permission for them to edit everyone's rows, but NOT administer tables, or just a permission to edit their own rows and my rows. Any suggestions?

Theming: This is a lot of work, but just curious, can you change the colors based on what theme you are using?

How to: How do you delete/add columns? I didn't see anything like that in the edit table page.

Thanks so much! (and to the person who created table manager... wow! :)

Anisa.

Comments

pobster’s picture

Hey that would be me! :o)

I'm away this weekend, but yes I will certainly take your comments on board (especially the one about permissions).

In the most current version of tablemanager you can actually delete columns although not add them yet (that's going to be a tricky bit of coding!!!) I'm working on it :o) It's an ongoing module...

Please be aware that I haven't written any update code for the most current version of tablemanager. So you *may* have problems updating if you installed a CVS version which allowed barcharts on ONE COLUMN ONLY. That idea was rubbish and so I binned it ;o) It was only perhaps available for download for a short while so hopefully no-one is using it and therefore I don't have to bother with any upgrade code! ;o)

Right - your suggestions:

Sorting: Nice idea, but I'm not sure I'm clever enough to be able to implement it... I'll give it a go perhaps though as it would be helpful.

Permissions: Yep - like it. Will try and implement it asap.

Theming: Well... Each different theme *should* have css tags for tables and as long as you don't have anything in the tablemanager settings messing with your css you should get your themes colour scheme in your tables... However... Having said that, I've noticed that every theme I have installed has a really boring colour scheme which is grey, grey and more grey... I'd highly suggest using tablemanagers settings page to set your css and then play around with the css in there (/modules/tablemanager/misc/)

How to: Well... Yeah I'm working on the add column part... I tried to do it before and it didn't work how I'd like it to work, but I'm more hopeful this time as I've changed things greatly since then. Like I said above though, you can delete columns all you like now with the newest version.

Pobster

pobster’s picture

Hey there :o)

Okay, I've updated the sorting function... It now sorts on the column you've clicked on, but if there's double matches it'll sort on the next column along. If that doesn't make obvious sense, here's an example:

New 03 Wilier Lampre Team carbon fork & Stays
New 04 Derosa Merak carbon fork & rear end
New 04 Giant TCR
New 04 Look AL384, Look Carbon Fork + Stays (Slope)
New 04 Look KX Lite full carbon
New 04 Massi CM4000 (no fork)
New 04 Massi CM4000, No Fork
New 05 Ambrosio Rapide (very small)

Notice that where the first column is the same, it sorts on the next column along instead.

I've also finished programming for the main permissions functions and so next I'm going to look into your idea for that... Watch this space! :o)

Oh and by the way, I've now finished both the add and delete column functions, the most current version should allow you to do all this now:

http://cvs.drupal.org/viewcvs/*checkout*/drupal/contributions/modules/ta...

Pobster

rivena’s picture

I will try it out and try to give you as much feedback as I can.

And thank you again for all your hard work on this module! You've put a lot of time in making this accessible, and it shows! :)

Anisa.

Running the upgrade script gave me this error:
* Failed: ALTER TABLE {tablemanager} DROP COLUMN type
* Failed: ALTER TABLE {tablemanager} DROP COLUMN misc

But since these don't exist, going to keep going! :)

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

rivena’s picture

Not quite sure that the sorting does what you say it does, sort on the next column when the first column is the same. My table is here:
http://www.animecards.org/node/66

I would expect that, if that were the case, the card sets would go Carddass Masters 1, 2, 3, instead of 1, 3, 2.

I am trying to think of ways to get this functionality to my very untechy users (soooooo not letting them touch php!). I suppose if I made the table for them, and then let them control it.... except that I wouldn't want them touching php so there is a minor problem.

Thinkthink.

I noticed the Edit Any Content permission, thanks!

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

I updated quite a lot yesterday getting some things done and fixed (well, updated as nothing was truly broken!) so it's possible if you just downloaded off the tablemanager module page that you've not got the most current version. To check take a look at the Id line, which should read like this if you're running the most up-to-date version:

// $Id: tablemanager.module,v 1.55 2006/06/21 17:05:20 pobster Exp $

If it DOES say that, please let me know as then my sorting function really isn't working properly :o(

Thanks

Pobster
PS. No worries about adding the 'edit any' permissions - it's a nice idea I like it!
PPS. And yep - you're quite right to ignore the 'failed' bits from the .install, as the module is in constant development I'm often adding bit and then taking them away before people have even tried installing them!
PPPS. Regarding your last comment about creating a page with a table on it for a user and then letting them control it... I've been thinking about this a lot lately as I'm not entirely happy with how it is either! ;o) I tend to prefer to keep the page permissions to myself to prevent a user having php access (which seems dangerous) and just giving them permissions for the table instead. Of course, this does prevent them from being able to mess around with all the function parameters, but most users won't be that bothered anyway I guess? I've been toying with having all the parameters in the 'tablemanager' table instead of in the function call itself... Problem is things start to get messy... If you think you'd perhaps use something like this then please say! You'd just call tablemanager_display_dynamic(1) for instance and it'd show a block or a collapsible table for the user who owns the table to be able to change the settings (parameters) in a gui rather than from the php?

pobster’s picture

http://www.ciclosuno.com/drupal/node/272?page=1&sort=asc&order=Type

I'm having concerns... As you can see from the link it appears to work on my test 4.7 site, but it's actually not perfect... I'll be very interested to hear from you regarding whether yours works or not...

My concerns stem from using strnatcmp which while seemed like a good idea I'm starting to wonder...

Pobster

rivena’s picture

As you suggested, it was an older version, and it works now.

For my very simple use in this one case, it works for me. But I wouldn't want carddass masters 1 to be different from Carddass Masters 1, and maybe some people would prefer to have a secondary sort on another column.

For example, sort by price and then title?

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Ah good stuff :o)

Right well in my newest version I've dropped the case sorting and gone with 'strnatcasecmp' so all case is ignored and things are sorted completely human like (ie. 1, 2, 3, 10, 11, 12 - instead of PC like 1, 10, 11, 12, 2, 3).

I'll release it later tonight I guess right after I've solved a problem I'm having with colspan...

...anyways... I went with the sort just passing onto the next column rather than the administrator specifying it because if for instance you have a sort on every column then you'd need to specify a secondary column for every single one... I figured it'd get a bit much? I really want to keep the basic parts of this module as simple as possible, mainly because I've written it for my Dad to use on a site I host for him. If it gets even slightly complicated then he just won't use it... Back to the point... I kind of figured that 99% of people would have a 'natural progression' pattern to their columns and having the next column along being the secondary sort seemed like a good plan? ;o)

Thank you btw! :o) If you hadn't of mentioned this I'd never have thought of doing it - and it makes so much sense!!! It's made my own site look a whole lot better for it too!

Pobster

pobster’s picture

Just took a look at your site and I forgot to mention something about the new version... (which I noticed as soon as the page loaded!)

...The new version has a 'feature' where you can restrict what's displayed (taken from the modules homepage):

If you wish to restrict the rows displayed you can do so by passing an array to the function like this:

print tablemanager_display(1, NULL, FALSE, array('column' => 2, 'start' => 'a', 'end' => 'h'));

If you wish to only show rows which match a string you can omit the 'end' key in the array:

print tablemanager_display(1, NULL, FALSE, array('column' => 1, 'start' => 'New 2006'));

For an advanced example; how to show everyone in a 'date of birth' table who is under 25 years of age:

print tablemanager_display(1, NULL, FALSE, array('column' => 3, 'start' => date('Y/m/d', mktime(0, 0, 0, date('m'), date('d'), date('Y')-25)), 'end' => date('Y/m/d')));

So you'll need to alter your php call to:

print tablemanager_display(2, NULL, TRUE, NULL, array ('cellpadding' => '5'));

Hmmmm I must learn how to use filters... This php call is getting far too long! ;o)

Pobster

mfitch’s picture

Hi -
I like tablemanager a lot!
I am using this code:

print tablemanager_display(1, null, false, array('column'=>'10', 'start'=>'m') ); 

I get blank lines = # of rows that do not = 'm' and then the lines I want.

Am I missing something?

Can I limit the columns that ARE printed? (I've got 14 columns and would really only like to print the first 4 in this page)

pobster’s picture

Ah yeah, on fixing one thing for someone I inadvertently broke that feature... Sorry about that! If you update the tablemanager module to the latest version it should fix that issue.

Thanks

Pobster
edit: please be aware that only specifying 'm' as a match means that tablemanager literally will not display anything unless column 10 IS 'm'... If you wish to display rows where that column begins with 'm', then you need to specify start = 'm', end = 'n' - this starts at 'm' and display everything up to (but not including) 'n'.

rentex’s picture

please be aware that only specifying 'm' as a match means that tablemanager literally will not display anything unless column 10 IS 'm'... If you wish to display rows where that column begins with 'm', then you need to specify start = 'm', end = 'n' - this starts at 'm' and display everything up to (but not including) 'n'.

Fantastic module youve done, its really needed in Drupal by "the folks"!

This sentence confuses me little, but the following is what I can't seem to get working:

1.- Table is created with several columns and rows.
2.- Lots of data is submitted.
3.- Create a new book-page and load this table here.
4.- Trying to filter using the examples that comes with the module (but I can't understand how the filtering works, because the results
don't seem logical to me).
- Example of what I want to achieve:
I want to filter out all rows that don't contain the word apple. In the type_of_fruit_column I have: green apples, yellow apples, red apples, yellow bananas, green bananas... How would the code look like if I want to filter out all rows that don't contain the word apple?

I tried using these variants but they gave me no results:

[tablemanager:4, NULL, FALSE, column = 6 | start = "apple"]
[tablemanager:4, NULL, FALSE, column = 6 | start = "apples"]
[tablemanager:4, NULL, FALSE, column = 6 | start = "green apples"]
[tablemanager:4, NULL, FALSE, column = 6 | start = "green" | end = "apples"]
pobster’s picture

The filtering code is only there because someone requested one for 'dates'. Actually that's a point... In fixing something a while ago, I bet I've broken that part (!) But anyways, the fact that it can be applied to *any* column, not just a date column is kind of a nice oversight :o) But that's the reason it works like it does (because it's expecting 'dates')...

[tablemanager:4, NULL, FALSE, column = 6 | start = "apple"]

This will ONLY return rows which have the *exact* match 'apple' in column 6 (that's human numbering incidentally, not computer numbering - so first column is '1' as expected).

[tablemanager:4, NULL, FALSE, column = 6 | start = "apples"]

Likewise, will ONLY return *exact* matches for 'apples'...

[tablemanager:4, NULL, FALSE, column = 6 | start = "green apples"]

Likewise, will ONLY return *exact* matches for 'green apples'...

[tablemanager:4, NULL, FALSE, column = 6 | start = "green" | end = "apples"]

Now this is back to front, in the alphabet 'g' comes after 'a', so I'm unsure how php will handle this... Lets just say you've actually done it the other way round (start ="apples" | end = "green"). This will return any *exact* matches for 'apples' and everything which is deemed 'higher' than 'apples' right up to 'green'. So it will return 'bananas' but not 'gum'... As 'bananas' is higher than 'apples' (obviously as 'a' is less than 'b') and it won't return 'gum' as although they both begin with the letter 'g' php takes the whole string into account and the second letter 'r' is less than 'u'.

As this function was intended for dates there's no facility for wildcards so you can't say 'apples.*' or anything like that. It's fairly simple to change the check to a perl regular expression type one though so that you could do this? I'm afraid time is something I'm very much short of at the moment though... If its important to you then I'll do it as soon as I can?

Pobster
edit: When I say, "only return matches for 'apple'" I really mean it! This means that unless the cell *only* contains that word and nothing else then it won't be returned. So it'll ignore 'green apples', 'red apples', etc... ONLY 'apple' will be returned! Sorry thought I'd make that a bit clearer! ;o)

pobster’s picture

This is the compare code at line 949:

          if ($date && $col == $date['column']-1) {
            if (strcasecmp($a, $date['start']) < 0 || strcasecmp($a, $date['end']) > 0) {
              $cancelrow = TRUE;
              break;
            }
          }

$a contains the current cell, $col the current column, $date['start'], $date['end'] and $date['column'] are obviously the start, end and column which are specified from the filter. The $date['column']-1 you see is because computers start numbering from '0' and $col is generated from the function (and hence starts from '0').

As you can see it was only intended for dates! ;o) I've not got my programming head on at the moment, so I can't think to give you a patch - just check out this page for now http://uk2.php.net/manual/en/ref.pcre.php If it doesn't mean anything to you - please let me know and I'll do it a bit later when I have some time.

Thanks

Pobster

rentex’s picture

Ok so it was initially intended for dates, but it should be possible with words (was it possible to filter by words in a previous version of your module, if that's the case would I loose any functionality by using that version instead).
Now I understand what "start & end" really does.
I tried filtering using words, but didnt get any results on "green apples":

[tablemanager:4, NULL, FALSE, column = 6 | start = "green apples"]

I have a non-technical and provisoric idea=)

1.- Make a new column for dates.
2.- Every time submitting an entry use a date for example: 1919 (1919 = green apples), 1920 (yellow apples).
3.- So when filtering I filter by using these dates as a reference, for example: show me all rows from 1919 and filter out the rest.
This would of course make the filtering a bit inflexible, but I can at any time create even more columns using "crazy dates" to refine/adjust the filtering, for example: show me all rows dated from 1919 to 1925. Or is it allready possible to filter in this way using only 1 column?

For example how would the neccesary code look like if I want to exclude all results not from year 1919?
And how to filter out everything not dated in the period 1919-1925?

Thanks for the fast response!

pobster’s picture

Yes! It is completely possible with words! As I said before it's a nice 'side-effect' (!) It's always been possible since the functionality was added, I think perhaps you're a little bit confused with what I wrote above... I confess it was a little more technical than I'd have liked...

Okay... Forget I mentioned about dates...

Here's a table:

ID fruit quantity

1 apple 50
2 banana 25
3 red apple 35
4 apple 13

Right! If you did this:

[tablemanager:4, NULL, FALSE, column = 2 | start = "apple"]

You'd have this displayed:

ID fruit quantity

1 apple 50
4 apple 13

And if you did this:

[tablemanager:4, NULL, FALSE, column = 2 | start = "red apple"]

ID fruit quantity

3 red apple 35

See? It only returns *exact* matches. If perhaps you wanted to return different colours of apples you could perhaps do this:

ID fruit quantity

1 apple (red) 50
2 apple (green) 25
3 not an apple 35
4 apple (pink) 13

Then you could filter by using start and end like this:

[tablemanager:4, NULL, FALSE, column = 2 | start = "apple" | end = "apple (zzzzzzz"]

Although this looks a little bizarre it'll work... Hope this helps shed some light!

Pobster

rentex’s picture

Thanks a bunch that makes everything much more clear too me, maybe it would be a great idea to include these examples you just posted with the documentation.

I thought this was the way it worked, but It didn't by me when I tried. I'm using table-manager version: 1.68.
Could you or anybody else please test and see if you get this version working by you using this kind of filtering (word), it might as well be a conflict between modules on my portal.

pobster’s picture

Well the functionality of that particular thing did change around the revision you're using so it's possible that before it had a bug which I wasn't aware of? I'd suggest just updating to the latest version? You've nothing to lose...

Pobster
PS. If it means anything to you, heres the diff between 1.68 and 1.71:

http://cvs.drupal.org/viewcvs/drupal/contributions/modules/tablemanager/...

rentex’s picture

I uploaded version 1.71, but it still doesn't give me any results when I try filtering by words.

pobster’s picture

Can you give a link to the webpage the table is displayed on?

Pobster

rivena’s picture

Good stuff, I agree that it can get rather complicated.

But my sort is looking kinda funny after I added a couple of rows.
http://www.animecards.org/node/66

The newest rows (added after I updated the module), float to the top, but they should technically be somewhere in the middle, right? Checked the sort, it's the default sort.

Editing one of the old rows brought it up back with the rest of the new rows.

Hm. Well, I suppose editing all of them would put it back in place, but I thought I'd mention it.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

On looking at your page source I noticed this:

<tr class="odd"><td class="active"><p>Kyou Kara Maoh!</p>

<br class="giImageBlock-clear-both" /></td><td><p>The First Box</p>
<br class="giImageBlock-clear-both" /></td><td><p>VASH</p>
<br class="giImageBlock-clear-both" /></td><td><p>Reg set + 5 sps + box2</p>
<br class="giImageBlock-clear-both" /></td><td><p>Y</p>
<br class="giImageBlock-clear-both" /></td> </tr>
 <tr class="even"><td class="active"><p>Spiral</p>

The reason these entries are floating to the top is because the sort is literally sorting on the <p> tag and so separating it from the others. Did you enter these manually? If not, then I'm not sure why they're not getting removed? You see, Drupal being Drupal (and not very friendly in places) adds these to certain filters - but I remove them like this:

  if (substr($temp, 0, 3) == "<p>" && substr($temp, -4, 4) == "</p>") {
    $temp = substr($temp, 3, -4);
  }

This code still works for me? So I can't seem to find out why it's not happening on yours...? One thing that is different are those "giImageBlock-clear-both" class tags... Are they from Gallery? If so, I guess I can ignore them as they're probably getting put in afterwards? Have you changed anything on your site filter wise which might be adding extra tags? I'm assuming here that my code is working - only there's perhaps either two sets of tags to remove or one set which doesn't end with "</p>" it ends with "</p> <br class="giImageBlock-clear-both" />"? Perhaps you're entering the new entries using the 'full html' filter and the old ones were 'filtered html'? But even then I'm sure that I accounted for that originally? Maybe something has changed since I did that? I *do* wish Drupal wouldn't add things to user input when you pass text through a filter it's VERY annoying :o(

Pobster

pobster’s picture

Ah... Now I have a big problem... I just tested my theory of it being down to the 'full html' filter and it does seem as though that has changed and is causing a problem... But... My problem is different to your problem! :o(

Here's my test source:

<h2>Our House</h2><table>

<caption>A table showing the occupants of our house</caption>
 <thead><tr><th type="1" required="1"><a href="/drupal/node/add/page?sort=asc&amp;order=Name&amp;edit[title]=test&amp;edit[body]=%3C%3Fphp%0D%0A++print+tablemanager_display%285%29%3B%0D%0A%3F%3E&amp;edit[format]=2&amp;edit[form_id]=page_node_form&amp;edit[ptype]=0&amp;edit[log]=&amp;edit[comment]=0&amp;edit[path]=&amp;edit[menu][title]=&amp;edit[menu][description]=&amp;edit[menu][pid]=1&amp;edit[menu][path]=&amp;edit[menu][weight]=0&amp;edit[menu][mid]=0&amp;edit[menu][type]=86&amp;edit[name]=admin&amp;edit[date]=&amp;edit[status]=1&amp;op=Preview" title="sort by Name" class="active">Name</a></th><th type="2" required="" class="active"><a href="/drupal/node/add/page?sort=asc&amp;order=Age&amp;edit[title]=test&amp;edit[body]=%3C%3Fphp%0D%0A++print+tablemanager_display%285%29%3B%0D%0A%3F%3E&amp;edit[format]=2&amp;edit[form_id]=page_node_form&amp;edit[ptype]=0&amp;edit[log]=&amp;edit[comment]=0&amp;edit[path]=&amp;edit[menu][title]=&amp;edit[menu][description]=&amp;edit[menu][pid]=1&amp;edit[menu][path]=&amp;edit[menu][weight]=0&amp;edit[menu][mid]=0&amp;edit[menu][type]=86&amp;edit[name]=admin&amp;edit[date]=&amp;edit[status]=1&amp;op=Preview" title="sort by Age" class="active">Age<img src="/drupal/misc/arrow-asc.png" alt="sort icon" title="sort ascending" width="13" height="13" /></a></th> </tr></thead>
<tbody>
 <tr class="odd"><td><p>Paul</p>
<br class="clear-both" /></td><td class="active">30</td> </tr>
</tbody></table>

Yours came back with that "<p>"..."</p> <br class="giImageBlock-clear-both" />" as you can see from above, mine comes back with "<p>"..."</p> <br class="clear-both" />". Yikes :o( I can't believe that Drupal think that adding tags to user input is okay!!! I'm at a loss for what to do here... I'm not sure... :o(

Pobster

pobster’s picture

/**
 * Sort function
 */
function tablemanager_sort(&$data, $field, $sort = "asc") {
  // reduce $field by one as it currently holds human friendly numbering - first column should be 0 not 1
  $next = $field;
  $field--;
  $code = array_key_exists($next, $data) ? "if (0 == (\$cmp = strnatcasecmp(strip_tags(\$a['data']['$field']), strip_tags(\$b['data']['$field'])))) return strnatcasecmp(strip_tags(\$a['data']['$next']), strip_tags(\$b['data']['$next'])); else return \$cmp;" : "return strnatcasecmp(strip_tags(\$a['data']['$field']), strip_tags(\$b['data']['$field']));";
  if ($sort == "asc"){
    uasort($data, create_function('$a,$b', $code));
  }
  else {
    uasort($data, create_function('$b,$a', $code));
  }
  return;
} // tablemanager_sort

It's the second from last function, please delete it and replace it with the above code and let me know if it 'repairs' your problem? I thought that rather than keep removing every single thing Drupal could add to a user input I'd just strip *everything* tag wise from the sorting function - this doesn't affect the tags being displayed, only how they're sorted.

It's seems to work okay here:

http://www.ciclosuno.com/node/300

(And yes I know that site is 4.6 not 4.7, I can't upgrade it until someone updates taxonomy_defaults!)

Thank you :o)

Pobster

rivena’s picture

Yes, I did add the gallery filter and lightbox filter to the filtered html thingy. That's a gallery CSS class... I have no idea why it would affect the BR tag. I am trying to minimize the number of input formats.

I did notice that, even though I didn't put them in, html tags appeared in field when I edited. I'll try the new sort function.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

rivena’s picture

There's still this thing with the html tags. I tried deleting them, but they pop back up.

For example <p>Tsubasa Chronicle</p>.

I have the HTML filter (actually p tags are not allowed...), line break, URL filter, Gallery filter, Lightbox filter, and a line breaker.

I set up another filter, just HTML filter and URL filter, that took out the tags.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

I don't think there's anything you can do to not have the tags... The problem comes from me passing the code through a Drupal function called 'check_markup' - this returns the user input passed through the input filter. It's this which is causing the problem... In version 4.6 of tablemanager I handled the input filters VERY differently and it was a Drupal dev who told me to do it this new way for the 4.7 version. I'm 99% sure the problem is with this API function and the 'Full HTML' filter... So :o( I'm afraid there's not a lot I can do about it tbh :o( It's a 'Drupal thing'...

I guess though as long as you only allow users 'filtered html' access then you shouldn't ever have a problem with it though? It's obviously not good to allow users full HTML access anyway? Well... Unless you know them personally ;o) Anyways, even with the tags that new sorting routine *should* work now... It's just annoying that there's linebreaks in the tables.

Please let me know if it works or not!

Thank you

Pobster

rivena’s picture

Hm. So the linebreaks don't show up with just normal filtered HTML. I don't have them allowed. It seems to be a problem only with one of the Gallery related filters. I tried it with full html without the gallery filters enabled, no problem. So perhaps it is a Gallery filter problem, not a drupal problem. :)

The sorting does work fine, so that's good! :)

Anisa.
oo, we've got 19,000 scans now!

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

In both the tablemanager_add_submit and tablemanager_edit_submit functions add this bit below:

...
    if (substr($temp, 0, 3) == "<p>" && substr($temp, -4, 4) == "</p>") {
      $temp = substr($temp, 3, -4);
    }
// Add this bit:
    if (substr($temp, 0, 3) == "<p>" && substr($temp, -43) == "</p>
<br class="giImageBlock-clear-both" />") {
      $temp = substr($temp, 3, -43);
    }
...

That's assuming you want to re-enable the gallery filters? I'm possibly a little bit out with the '-43' above as I forget how many characters the newline is? If it doesn't detect it try increasing both the instances of '-43' up one...

I'll commit the updated sorting routine when I'm finished with the next update (the duplicate function) - I'm nearly done, but I've been ultra busy with work and I've not even touched it today :o(

Wow! 19,000 scans! That's huge!!! Your site is fantastic! :o) I'm quite proud that you use my little module on it!! ;o)

Pobster

rivena’s picture

A function just for me? I feel special now. ;) Maybe if I just change the order of the filters, the html filter will strip the Gallery filter for me, and you won't have to worry about it anymore.

19,000 scans sounds like a lot, and I put it up to impress people, but when a collector looks around, it's, why isn't there this, why isn't there that. ^.^;;; So there's never that feeling of satisfaction. There have been three major donators who really pushed the site along, and bumped up that number, without them, the site wouldn't be anything. I am kinda proud of it, though... I've been doing it for five years now.

And your little module is great! And not so little! I wish I could do stuff like that, I wish I knew more, I'd be able to do all I wanted with ACO right now.... and make so many customizations that when 4.8 comes out, I'd be stuck. ^.^; Frozen forever in 4.7, with its field limited freetagging.

I am going to Anime Expo, so hopefully, many many more cards to scan! Thanks again for all your help! Let me know if you need any more feedback, happy to help!

Anisa.
PS: I love your little smiley faces with the round noses... ^.^

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

>PS: I love your little smiley faces with the round noses... ^.^

Hehe :o) I like yours too! And yes, you are very special :oP And if you can think of anything else to help me make my module better then please let me know!! ;o)

I do feel though the next update may be a little slow in coming, work is a bit busy lately... It'll be along asap - promise!

Pobster

rivena’s picture

I just thought of something random today... What about an import data option? To add large amounts of data to a table all at once instead of row by row. That'd be really spiffy!

No worries, I am going on vacation myself, shopping at Anime Expo, yay! I do hope there are enough trading cards...

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

Anonymous’s picture

Just curious if you've tried this and if so how well does it work?

I noticed when you have filters like BBCode or Img_Assist enabled, an extra <p> tag is added to the table. Since disabling the filters would make other content look weird, I just created a separate input format just for the tables, which works. But if there was a way to bypass the filters, that would be great >.>

rivena’s picture

I ended up doing that too... Problem was, when other people add entries, they tend to forget (I put it in big letters!) to select that input format.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Unfortunately due to the way Drupal works it's very difficult to remove every different 'thing' Drupal can add to your entries. It's stupid as it makes things like Tablemanager so much harder to program... BUT :o) I'm currently working on a rewrite and I have plans for a workaround... I'm not sure if it'll work as I hope or not - only time will tell! Another 'unfortunately' is that I have less time these days and so it'll be quite a while before a cvs version is available...

...Watch this space!

Pobster

pobster’s picture

...Actually... Now would be a good time to make suggestions for new features! ;o)

Pobster

rivena’s picture

Fix the selection box. ;p
A few LESS browser refreshes would be nice...
Duplicate table, duplicate entry, duplicate column.
Add by CVS to an already created table.
More kinds of fields, like node reference or user reference.
Perhaps incorporate taxonomy, give it more flexibility.
Exposed filters for tables (like sourceforge?)

Drupal in general is kinda clunky with the interface, but they are dramatically changing the admin interface for 5.0... maybe taking a look at that will give you some ideas.

Being able to select different input formats for different fields/columns might be interesting.

Anisa.
Calling me princess... take that! ;p

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Hehe :o) Sorry - that's the cockney in me coming out ;o) Gotta give people you like pet names!!! :o)

>>Add by CSV to an already created table.

Didn't I already do that one?

>>Duplicate table, duplicate entry, duplicate column.

Yep - current CVS has duplicate table which works nicely but hmmm... duplicate entry/ column? I think that may be a bit overkill? I'm not sure whether it'd make the GUI a bit too ... busy? What do you think?

>>Fix the selection box. ;p

Yeah! I wasn't aware of that problem until yesterday when I read this thread! No worries, I'll see what I can do!

>>More kinds of fields, like node reference or user reference.

CVS already does this (well... user reference anyway - node reference isn't core), I just stopped development of the 4.7 branch for a bit while I'm working on the HEAD version.

>>Perhaps incorporate taxonomy, give it more flexibility.
>>A few LESS browser refreshes would be nice...
>>Exposed filters for tables (like sourceforge?)
>>Being able to select different input formats for different fields/columns might be interesting.

I'm a bit lost with these suggestions? Could you expand on what you mean please?

>>Drupal in general is kinda clunky with the interface, but they are dramatically changing the admin interface for 5.0... maybe taking a look at that will give you some ideas.

Yep! That's what I'm doing currently! :o)

As always though ;o) VERY much appreciated! Thank you! :o)

Pobster

pobster’s picture

Hehe :o) Incidentally...

>>Calling me princess... take that! ;p

Where's your proof?!!! ;o) You had the evidence deleted!!!! :oP

Pobster

rivena’s picture

You just admitted it! ;p

What do you mean, people like me? ;) That better be gorgeous and kind, not high maintenance and demanding. ;p

Anisa.
well, gorgeous anyway. ;)

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Hehe :o) See, I like you even without the knowledge that you're gorgeous!! Of course, now I know - I like you even more!... Princess ;o)

Pobster
- X -

rivena’s picture

^.^ Developers are funny people.

If I were going to let my users at this module, I would want it for something like their being able to make their own trading card trading list. Some of them collect tons of different cards, some of them collect only a few. So they would need to be able to create several tables.

They would need a simple gui interface that will let them type in the table name, # of columns, header names. Default sorting as well.

A problem I see to letting them make their own tables is they will need to insert their table in a page or a cck content type. They might not get it, and it's lots more extra steps for them. Still, I could write out the appropriate instructions. I would use the view table filter module, though, not php.

Permissions wise, the only people who can muck with a user's table are me and the user herself. Even if I end up making the table myself for whatever reason, I want to be able to assign that table to her. With a book page you can change the authorship of a page, can you do the same for a table?

Also, for a person with appropriate permissions, I'd love for the ability to display a 'add a row to this table' and/or 'add a column to this table' WITH the table itself.

Still seems in many ways an administrator's tool. Maybe if there were a way to insert a table into a node like you can do an image? Or better yet, a 'insert your table here' type tool! Something that would pop up with a select list of tables that user has created, user selects, and it inserts the view table code into the node body.

Anisa.
full of wishful thinking!

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

I'm not a developer at all, but point taken about being a bit funny ;o) That is completely true!!!! For instance... As you've just pointed out - I've completely forgotten to give a permissioned user a link on a table page to add a new row... Doh! That's pretty stupid seeing as you can enable the edit and delete links... I'll do that tonight (hopefully) I think I got a bit carried away with putting the links in the create content page, I've no idea why though as my users are all administrators and so will never bother using that anyway...

There's a clue in that above paragraph as to why my module is geared towards being an administrators tool ;o) I guess I could try my hand at allowing permissioned users to create tables? All the ground work is done already I suppose? Leave it with me and I'll look into it (although please bear in mind that I only really do module type stuff during the week)

Thanks for your suggestions! Again, they're not things I'd tend to think of myself and so are greatly appreciated! :o)

Pobster

rivena’s picture

whee. :)

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

rivena’s picture

Maybe it would be easier for you to keep it an administrator's tool. It's already so remarkably configurable, and any admin could whip up a table in 5 minutes, 2 if the server were loading fast.

The create content links were a bit much... Does ANYONE use them, I keep having to hide them. ^.^; And yet how un-drupally if you didn't have them.

I am trying to think of cases where the user wouldn't want a perfect title ABC sort. I think sometimes when people group stuff together, it might get out of order. For example, in my case, someone might group the G-fantasy cards with the Saiyuki cards. If you want ultimate control over a table, maybe you could have a custom sort option, and then maybe control rows by weights or 'move this row up/down' (tedious if you have a lot of rows). Or use a weights by typed in number, click on update when you are done.

I know! What about a duplicate table function? There's one like that in Views, so you don't have to do everything all over again if you are creating two very similar tables.

If you find the feedback helpful, I'll keep giving it! ^.^ I know I find it really helpful when users complain about my site, I know what to fix instead of guessing all the time.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Whoa! See I'd never have thought of that!! Yes - I like the duplicate table feature, VERY easy to implement and obviously very handy!!! :o) Yep - I'll put that in asap (although as I said before I never really do much module wise on a weekend) that's an excellent idea thank you!

I agree about the create content links, I don't use them - nobody really said they wanted them as such... But of course, as you say - how un-drupally not to have them! (Heh, that made me laugh! Well put!) I'm currently toying with having a 'create table' link in the create content page with a new permission for 'create/ administer own tables' - I guess that'd make more sense for the table entry links in the create content page as it'd kind of group things together? They're still a little bit redundant though as you'd have the admin links on the actual table page so you could still add new rows from there... Bah, well... Whatever ;o)

I'm not sure that adding weights to entries would be such a good idea? I feel it may over complicate things or perhaps just make the screen too cluttered? Not sure... I'm more inclined towards the simple move up/ move down function just set from the order entries are put into the database. That'd be EASY :o) I like easy ;o) Currently, when there's no default sortable column set, things are just displayed in order of id (which is incremented by one for every single entry - so first in, first out (FIFO)) I guess I could just have a checkbox next to every row and then a link somewhere for move up/ move down? And then just swap the 'id' for that column and the one above or below it? That'd work? ...And also might be quite useful? On my Dads site, there's a list of events in a table and if something gets added in the middle of the table it *is* a pain moving everything manually... Mind you... Now you can sort properly by dates so I could just change the type... Anyways, I do still like the idea of a manual sort - will try and implement that as well. You're full of good ideas!!! :o)

Pobster

rivena’s picture

Now I have TWO tables! Yay. ^.^;

When I went to update.php, it said there were no upgrades for tablemanager... I went ahead and ran it anyway, but was it necessary?

Is it possible to have an insert table filter thingy, as there is for views? That way users could insert it without having php permission?

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Hello again! ;o)

Hope you got some nice new trading cards while you were away?!! I'm afraid I took a break from tablemanager for a little while as I felt I was getting a bit 'stale' with some of the problems I was having, but anyways I'm back on the case again now :o)

It's always good to run update.php after updating any module and if it tells you that you don't have any updates before you run it, running it anyway doesn't hurt! It just doesn't do anything! ;o)

I'm afraid there's good and bad news regarding filters...

The good news is that I thought it was about time I gave them a go, so the version you have does actually allow you to use them (enable the tablemanager filter in admin/filters).

And the bad news is... Although they work... I'm afraid they don't allow you to sort columns or click on the pager links and I've (currently) no idea why! Everything looks okay? Meaning, it gets displayed okay - but when you click on anything nothing happens!!! I'm trying to sort it out now, so hopefully I'll get to the bottom of it soon... Watch this space! ;o)

Pobster

rivena’s picture

Not quite as many as I would have liked, but I have a nice selection of One Piece cards... some how I ended up with more rare One Piece cards than anyone I know. It's lonely, being the only person who collects something!

And there was a hot guy dressed as Luffy's older brother whose name escapes me, but you wouldn't be interested in that! ^.^

As far as filters, I am sure you'll the answer! I myself am getting very lazy about fixing bugs. I ignore them all.

Actually there was another thing with table manager... Before I upgraded to the latest, I wanted to change the sorting order of my 2nd table from desc to asc or the other way around, I forget, and it gave me this error about bar graphs?? even though it's not a bar graph.... But when I upgraded and tried changing, it was fine.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Nothing wrong with being a lonely collector!!! I collect things that not many people collect, just not trading cards ;o) I collect 1980's arcade machines and I've currently got quite a few!!! My favourites are my Pacman, Asteroids and Star Wars machines and I get all geeky and sentimental about them whenever anyone feins the remotest of interest in them :oP It's quite sad really ;o)

Anyways, surely you mean Ace? http://en.wikipedia.org/wiki/Portgas_D._Ace - Yeah, I look like that without a top on too ...*cough*! Well maybe 9 years ago when I was 21 I did anyway! ;o)

Pobster

rivena’s picture

Hihi. I was dumb and didn't give authenticated users proper permission to add a new entry, so the add new entry tab didn't show up . However, even when I did give them create 'scans to be donated' entries permission, it didn't show up. I had to give them administer tables permission, and hope that they don't find how to muck with it while I report this. ;)

So, basically, the link should show up if they have create entry permissions for that table, AND/OR they have administer (or administer/create) permissions.

Anisa.
PS: Yes, I mean Ace. Plenty of guys show up scantily clad at anime cons, but this guy had the abs to really pull it off.
PPS: Looking at the pictures of Ace, I am no longer sure it IS Ace, but it IS an anime character I have seen before.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Yikes!!! Right!!! :o) Seems when I fixed something for someone else, I didn't remove all the single quotes from every argument like I thought I did...

In the tablemanager_display function (near the end) change this:

  if ($links) {
    $table .= ($user->uid == $result->tableuid && user_access('administer/ create own tables')) || user_access("create '".tablemanager_fetchname($tid)."' content") || user_access('administer tables') ? '<p>'.l(t('Add new entry'), 'node/add/tablemanager/table-'.$tid) : '';
  }

To this:

  if ($links) {
    $table .= ($user->uid == $result->tableuid && user_access('administer/ create own tables')) || user_access("create ".tablemanager_fetchname($tid)." content") || user_access('administer tables') ? '<p>'.l(t('Add new entry'), 'node/add/tablemanager/table-'.$tid) : '';
  }

See all you're doing is removing the pair of single quotes so it matches the user_access erm... 'thingy'... *cough* /professionalism off

I'll make a new release asap.

Pobster

rivena’s picture

Hihi! My hard drive died, but I had some unusual foresight, so my entire site is all backed up, safe and sound. Still paid $500 to get the data retrieved (pictures and whatnot), but I got a nice shiny external hdd out of it, so all is good.

I am expanding my use of table manager! I am making a little task list. There is a task list module, but it was a bit much for me, I just want a little table. I am sorting problems by Series and Set, set links to the actual set in the gallery. It's not a big deal to rewrite the series set part, but the link is a pain to duplicate again.

I found a bunch of old original sized scans that I need to update in the Gallery, but I am lazy and it won't improve my scan count, so I think I'll pass it off to the admins. ;) I have 2 now, it's exciting!

Additionally, I don't suppose it's possible to have different input formats for different fields?

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

zick’s picture

Hi, I'm just wondering is it possible to use the tablemanager to display the data from another database? Cause all my data are in there.

thanks

pobster’s picture

Without wanting to sound rude... How on earth could it be possible? Tablemanager isn't magic you know? ;o)

If it's possible to export your table in a csv format (comma separated values) then you can copy the csv into tablemanagers csv import function and tablemanager should be able to create a table of its own from that?

Pobster

zick’s picture

Yes, after looking at the data format in tablemanager_data, I believe it's not possible......

But still, thanx for providing such a good module.

Zick

pobster’s picture

You know it's pretty easy to 'load' the table api with entries from any database and then just pass the theme('table', ... function to display it. If you really need to display your table on your site, I'd be happy to help guide you through a php snippet?

Thanks

Pobster

zick’s picture

Yes, cuz I'm new to Drupal, it would be really appreciate if you can help me with a guide.

thanx!!

pobster’s picture

Hello again ;o)

Hmmm I didn't say a 'guide', I'd said I'd help '...guide you through' which is subtly different!

Post here how your db is structured and I'll give you some examples of how to pull data out of it and into a themed table.

Pobster

zick’s picture

It's an inventory db(not in the Drupal db). I want to display the data in the table named 'items', which has 13 columns, like itemid, manufacturer, datepurchased, etc. I want to display 5 columns, and itemid is also a url link which link to the item detail page.

Currently, I have that partially done by hard coding, with all html tags,

...... I want to use the tablemanager because it will make the table looks better, easier to manage later, and the sortorder function...

I'll really appriciate your help.

Zick

pobster’s picture

I think you're getting your wires crossed here... I said that I'd help you with sending your current data straight to a Drupal table (http://api.drupal.org/api/4.7/function/theme_table) I never mentioned helping you with importing your db into tablemanager... I get several requests a month for custom importing functions when it's very easy to do it with the tools you already have. All you really need is - notepad and tablemanagers csv import function...

I can talk you through either using theme('table', ...) or importing data into tablemanager? Which is it that you want to do?

Pobster

zick’s picture

Yes, my mistake. I think the theme_table can do what I want. Because my db changes every day, importing it every time seems not that good.

So, a little hint of how to use the theme_table will be appriciated. And is there any good way to handle the sorting? Currently what I'm doing is reset the SELECT query every time the user click the table header, but I think reload the data from the db every time is not a good idea. BTW, can you show me how to display the data in multiple pages?

thanx

pobster’s picture

Okay I'm just going to show you a few examples of 'practise':

/**
  * Creates a neat table of flexinode titles from a specified term
  * with a link to each one and 'submitted by...' information.
  *
  * $field_id must point to the flexinode field which contains the date.
  * To change which term is listed, simply edit the $term_id string.
  * To change the number of results listed, simply edit the $list_no number.
  *
  * This works with Drupal 4.6 and Drupal 4.7
*/
  $term_id = 75;
  $field_id = 9;
  $list_no = 25;
  $prev_year = '';
  $sql = db_rewrite_sql("SELECT n.nid, n.title, n.created, u.name, fl.numeric_data
          FROM {node} n
            INNER JOIN {users} u ON n.uid = u.uid
            INNER JOIN {term_node} tn ON n.nid = tn.nid
            INNER JOIN {flexinode_data} fl ON n.nid = fl.nid
          WHERE tn.tid = %d AND fl.field_id = %d
          ORDER BY fl.numeric_data DESC");
  $result = pager_query(sprintf($sql, $term_id, $field_id), $list_no);
  while ($anode = db_fetch_object($result)) {
    $year = format_date($anode->numeric_data, 'custom', 'Y');
    $month_day = format_date($anode->numeric_data, 'custom', 'M j');
    if ($year != $prev_year) {
      $prev_year = $year;
    }
    $output[$year][] = array(array('data' => $month_day), array('data' => l($anode->title, "node/$anode->nid")), array('data' => '<em>Submitted by '.$anode->name."</em>"));
  }
  foreach ($output as $year => $table) {
    print theme('table', array(array('data' => '<h3>'.$year.'</h3>', 'colspan' => '3')), $table);
  }
  print theme('pager', NULL, $list_no);

I obviously can't show you examples from your own table as I don't have that information ;o) So instead I'm going to explain the code above a little.

First off, don't worry about the 'db_rewrite_sql' that's only necessary when dealing with nodes (it's for security). It's the pager query stuff you need to take notice of, that's how Drupal handles pagination. It's pretty evident how it works following the (short) example above, just look at what the $list_no variable does and obviously the 'pager' bits...

If you take a look at: http://api.drupal.org/api/4.7/function/theme_table it'll tell you all you need to know about sorting dynamically (although I think it's written quite badly myself!) Anyways, it works quite well as long as you follow those instructions. You need to set your header properly for a start, as it says including a unique field id for each column to be sortable. You can then use Drupals tablesort functions together with your sql query to get mysql (or whatever you use!) to sort your tables for you. I'm afraid I don't have a proper example for this, only how tablemanager does it (which is different because tablemanager sorts the tables itself rather than rely on mysql):

  $temp = tablesort_get_order($header);
  if ($temp['sql']) {
    tablemanager_sort($rows, $temp['sql'], tablesort_get_sort($header));
  }

It's pretty straightforward to follow I should think! :o) Read about it here: http://api.drupal.org/api/4.7/function/tablesort_get_order

Hope this helps, if you need anything explaining clearer - please let me know.

Pobster

zick’s picture

OK, it worked.

Although I'm not 100% sure what it did for each part(I'm not sure why it's $output[$year][],), but following your example, I got my table displayed.

But I'm having a issue here. The table header appears above each rows. In another word, it is one row header, one row content, one row header, one row content......

The table from OP's link is what I want mine looks alike.

Here is my code:

	db_set_active('mydatabase');
	$query = "SELECT * FROM {items}";
	$queryResult = db_query($query);
	while ($links = db_fetch_object($queryResult)) {
		$itemid = $links->itemid;
		$inventoryno = $links->inventoryno;
		
		$output[$itemid][] = array(array('data' => $inventoryno), array('data' => l($links->itemid, "mitemlist/mitemdetails/" .$itemid)), array('data' => $links->description));

	}
	db_set_active('default');
	foreach ($output as $itemid => $table) {
		$page_content .= theme('table', array(array('data' => 'inventoryno'), array('data'=> 'itemid')), $table);
	}

	return $page_content;

The itemid is the PK and I'll leave the sort and pager thing later.

thanx again.
Zick

zick’s picture

OK, I figured it out!!

My solution is store each of the item in a row, which gives me a rows[], and use theme(......, rows)

Works good. Now, I'll start working on the sort & pager things.

thanx!!
Zick

pobster’s picture

Hello! :o)

Ah good stuff, sorry I should have given you this link:

http://www.ciclosuno.com/results

That's the output from that php snippet I wrote, so you see the reason you load up $output[table_id][] like that is that we're creating more than one table, hence the foreach (table_id as separate_table) print ...separate_table etc... as I needed to loop through each table to display it. Sorry I meant to explain that a whole lot clearer ;o) Obviously if you've only one table you'd just use $output[]... and simply print theme('table', $header, $output); to display that one table.

The pager links are pretty easy btw ;o)
You literally just add this:

$list_length = 35;

Change this:

$queryResult = db_query($query);

To this:

$queryResult = pager_query($query, $list_length);

Then finally stick this near the end of your code:

$page_content .= theme('pager', array(), $list_length);

Anyways, post on here if you're having issues with your code and I'll do my best to help out.

Thanks

Pobster
PS. Obviously untested as I've not got your database here, but here's a quick stab at it:

    $list_length = 35;
    $header = array(
    array('data' => t('Inventory No'), 'field' => 'inventoryno', 'sort' => 'asc'),
    array('data' => t('Item ID'), 'field' => 'itemid'),
    array('data' => t('Description'), 'field' => 'description')
  ); 
    db_set_active('mydatabase');
    $query = "SELECT * FROM {items}";
    $query .= tablesort_sql($header);
    $queryResult = pager_query($query, $list_length);
    while ($links = db_fetch_object($queryResult)) {
        $itemid = $links->itemid;
        $inventoryno = $links->inventoryno;
       
        $table[] = array(array('data' => $inventoryno), array('data' => l($itemid, "mitemlist/mitemdetails/" .$itemid)), array('data' => $links->description));

    }
    db_set_active('default');
    $page_content .= theme('table', $header, $table);
    $page_content .= theme('pager', array(), $list_length);
    return $page_content;
zick’s picture

Ohhh, this is exactly what I want! Simple and amazing!!!

A few more questions:
How to adjust the width & alignment for each coloum?
And how to add vertical lines between the columns?
I have another smaller table, with similar db structure. But I need to build that table with the header on the left, not top. So how to do that?

thanx a lot
Zick

pobster’s picture

Wow! Does what I wrote work then??? :o) That really is amazing!!! ;o)

Regarding attributes, this page is your friend:

http://api.drupal.org/api/4.7/function/theme_table

The attributes for different parts of the table are placed in different places in the code (as per the instructions in the friendly page above!), for instance to add a border, you'd change this line to affect the <table> tag:

$page_content .= theme('table', $header, $table);

To:

$page_content .= theme('table', $header, $table, array('border' => '5'));

For the slightly more complicated column alignments, you'd change this line:

$table[] = array(array('data' => $inventoryno), array('data' => l($itemid, "mitemlist/mitemdetails/" .$itemid)), array('data' => $links->description));

To:

$table[] = array(array('data' => $inventoryno, 'align' => 'center'), array('data' => l($itemid, "mitemlist/mitemdetails/" .$itemid), 'align' => 'center'), array('data' => $links->description, 'align' => 'center'));

Obviously you can add as many attributes as you like so you'd do the same for cellpadding and such.

As for the 'gridlines' you can do those with css although I believe some themes have them anyway? If you don't fancy doing any of that you can simply add them as a border attribute like this:

$table[] = array(array('data' => $inventoryno, 'border' => 'right'), array('data' => l($itemid, "mitemlist/mitemdetails/" .$itemid), 'border' => 'right'), array('data' => $links->description));

It should look fine, especially if you have a border around the whole table as well! :o)

Your other table will be tricky... There is no API help in building a table this way... You'd have to perhaps have a 'border' => 'right' attribute for the first entry in the row (which would be the 'header' for that row) then just build the row as normal from sql. Then repeat for the next 'header' and row... Build it that way.

Hope this helps! Please get back to me if you have any more questions.

Pobster

zick’s picture

Yes, they worked perfectly!! And this really helps!!!!!

And I've got some new questions (sorry for so many questions:)

On some pages, I have more than one tables on that page. But by default, the tables are in a stack instead of side by side, which is the style I want. So, is there any 'Drupal' ways to make them displayed side by side?

Another question is not really about the table: How to get the current user's username? Cause I need it displayed in a cell.

thanx
Zick

pobster’s picture

Hellooooo again, no worries I don't mind helping (although it has to be said the last 5 or 6 times I've posted asking for help, absolutely no-one replied!!!)

You need to use div tags to align things side-by-side (although I guess you could build a table of tables? might get a bit complicated!!!)

I have to admit I actually don't know anything about css and theming... I know it's something to do with <div class="container-inline"> but I can't explain what I don't know! ;o) Maybe use the search on here to find out more? Anyways, here's how I'd do it myself:

return '<table><tr><td>'.$table1.'</td><td>'.$table2.'</td></tr></table>';

Okay maybe it's not that neat... But it works nicely :o)

To get the username you need to put the following as the first line of your snippet:

global $user;

You can then access everything in the $user object for instance try these:

print_r ($user);
print $user->name;

Pobster

pobster’s picture

Incidentally... I forgot to mention pager 'elements'...

http://api.drupal.org/api/4.7/function/theme_pager

As you're going to use two (or more) tables on one page then you'll need to pass an identifying element to the pager function to distinguish which tables paged entries are being viewed. The default is to pass '0', so simply pass '1' to the second pager call.

Pobster

zick’s picture

Thanks alot, it helps a lot.

I'll start working on table printing next week and will come back and ask you some more questions if I have(I'm sure there will be some:)

Zick

pobster’s picture

Course, no worries - glad to help!

Good luck! ;o)

Pobster

zick’s picture

Hi, I'm back here for more questions:)

Currently, I'm trying to print the table as part of my report. I found some modules that could help print friendly page and generate PDF file, but they are all for drupal nodes only. My table and other content are all rendered by my module, which is not supported by those print modules.

So I think I need to customize my own print module. What I need is simple, just add a link on the page, click it to have a friendly page preview, which has a report title, some content from the original page(like the table, some text,etc), and without the side-block and Drupal title.

I know I can draw a new table on the print preview page, but that's not the universal solution for all my pages. So, any hint here?

thanx
Zick

pobster’s picture

Well obviously as I didn't write the print module I'm not familiar with how it works but it should be pretty simple to just create a custom version of it's main display function.

/**
 * Outputs a printer friendly page.
 */
function print_generate_node($title) {
  global $base_url;

  /* We can take a node id or a node title */
  $node = (is_numeric($title)) ? node_load(array('nid' => $title)) : node_load(array('title' => $title));
  if (!$node->title) return false;

  $teaser = false;
  $page = true;
  /* This section is ripped from node_view.
     This does everything node_view does except theme the node! */

  // Remove the delimiter (if any) that separates the teaser from the body.
  // TODO: this strips legitimate uses of '<!--break-->' also.
  $node->body = str_replace('<!--break-->', '', $node->body);

  // The 'view' hook can be implemented to overwrite the default function
  // to display nodes.
  if (node_hook($node, 'view'))
    node_invoke($node, 'view', $teaser, $page);
  else
    $node = node_prepare($node, $teaser);
  // Allow modules to change $node->body before viewing.
  node_invoke_nodeapi($node, 'view', $teaser, $page);

  /* End of code stealing from node_view() */

  // associative array settings
  $print_settings = variable_get('print_settings', NULL);

  if (!isset($print_settings['urls']) || !empty($print_settings['urls'])) {
    /* Collect links and display them at the bottom of the page. Code once taken from Kjartan Mannes' project.module  */
    $pattern = "@<a.*?href=([\']?[\"]?)([^\"|^\'|^|^>]*)([^>]*)>(.+?)</a>@ise";
    $node->body = preg_replace($pattern, "'<u>'.stripslashes('\\4').'</u> ['. print_friendly_urls(stripslashes('\\2')) .']'", $node->body);
    $urls = print_friendly_urls();
    if (count($urls)) {
      $node->pfp_links = '';
      $max = count($urls);
      for ($i = 0; $i < $max; $i++) {
        $node->pfp_links .= '['. ($i + 1) .'] '. $urls[$i] ."<br />\n";
      }
    }
  }

  $node->logo = !empty($print_settings['logo_url']) ? $print_settings['logo_url'] : theme_get_setting('logo');

  /* Grab and format the src URL */
  $node->source_url = $base_url . url("node/$node->nid");
  $node->language = $GLOBALS['locale'];
  $node->printcss = empty($print_settings['css']) ? 'misc/print.css' : $print_settings['css'];

  $robots_meta = _print_robots_meta_generator();

  include_once('print.node.tpl.php');
}

If you follow the code you'll see that all it does is 'load up' the $node object with the data it needs to display on the printer friendly page. All you have to do is pass your custom function the data you need to display on that page and create a printer friendly link to display that custom function. Job done!

Pobster

zick’s picture

Yes, that's what I'm thinking. It seems the print friendly page has to have the same function the original page have.

And I got two questions here:
1. How to hide the title logo, navigation bar, and side block for my print page? I looked thru the print module, but didn't find where the trick is.
2. How to make the print page open in a new browser window, instead the current one?

thanx
Zick

pobster’s picture

Hi, look not trying to be funny but when I said I'd help you - I only meant that I'd help you through the table building/ displaying stuff and I think I've aided you with that pretty well. This next set of questions are about things I know nothing about unless I actually look into them and I'm not about to start looking into things unless it's for my own gains... I'm sorry to have to put my foot down so firmly on this but I think you've strayed so far from the area I said I'd help you with that I've got to start saying 'no' now.

Everything you need to know about what you want to do can be gained from looking through the print function code above. Place it into your own module, create a menu CALLBACK for it (obviously renaming it so it doesn't clash with the print module) and simply play with it. Making it open in a new windows is easy, when you create the link for it on the main page just use target="_blank".

Please don't ask me any more questions regarding this as I will not reply. However, should you have any questions at all about your tables/ table function/ table code, then please ask away and I'll be only too happy to answer.

Pobster

zick’s picture

Sorry for asking questions you're not familiar with. Thank you for your time and so much help you gave me so far.

Zick

rivena’s picture

Maaaaaaaaaaaaaaaybe this would be too difficult, but what about adding fields-types to tables? For example, User Select, or Numbers only? Or how about an autoincrement feature? ID numbers, let's say.

I don't really have too many problems with this, but for example, for Status fields, I would rather have the user select from pre-defined fields than make it up themselves. Right now it's just Y or N (super simple, no one can mess it up ;), but I would like Y - processing. N - soon.

This thread is getting a bit long, would it be better to file feature requests instead?

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Helloooooo :o)

TBH this was my overall goal with tablemanager, I've coded it to be easily 'upgradeable' for adding new field types. It wasn't next on my 'to-do' list (to add some more I mean) but I can make it next if you like? :o) Currently I'm struggling over adding cell attributes, so it'd be a welcome rest!!! ;o)

I'll start on adding a selection box feature this week, it shouldn't take too long.

Pobster

-- ArcadeGeek.co.uk --

rivena’s picture

^.^ In that case, I want a select list, a node reference list, a user reference list, and maybe I'd like a URL field, where you can put the link and the link title.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Consider it done ;o) I'll make a new release into cvs each time I've completed one of the tasks and when they're all done (and tested) I'll merge the cvs branch with the 4.7 one...

...Mind you that said... I can't seem to find any instructions regarding 'node reference' or 'user reference' usage... :o( Meh, I'll play around with it - watch this space! :o)

Pobster

rivena’s picture

CCK has it, if that is any help. I would imagine it is similar, or at least it will give you some idea.

One of my users (whom I adore), asked me to make the Anime Series taxonomy links go to the gallery instead of a list of posts... and make an html howto page... sigh... turn down one, you have to do the other!

Anisa.
Booooooooooooooored.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Ta darrr!!! :o)

Okay I've just released 1.70 which allows cell attributes (needs testing) and also allows the data type 'Selection' (also needs testing!)

To use cell attributes:

When adding/ editing a cell try typing [bgcolor = yellow] it *should* automagically change that cells colour to yellow (and the code used to call it won't be displayed when using the main display function).
You can currently use align, axis, bgcolor, class, valign but there's no limit to what can be put into the list - so if anyone has any suggestions then they're easily put into the code.

To use the 'Selection' data type:

When you either create a new table or add a column to an old one, the data types dropdown box will now contain 'Selection', so errrr... Select it... Right ;o) You'll notice there's a new (collapsed) option for 'Selection' which when expanded will show a large-ish textarea. Enter your selection box choices in this box separated by a newline, eg:

2006
2005
2004
2003

It currently works... I think... But it's had lackluster testing and I know that I've forgotten to include validation (your selection box can contain NO choices AND be required - so a user would get stuck!) which I'll do next release. But then this is way its cvs right? ;o)

Pobster

-- ArcadeGeek.co.uk --

reqIUm’s picture

Hey this is great! Im building a large dance timetable n this's just what i need: ive gone and installed it 2nite. I am hoping that you could help me out with one issue and a feature (i can tell you like addin features?) ;)

Im building a large dance timetable, and the thing is that lessons are always being postponed, rearranged or shifted because of instructor availability.
So i have made this table where i have lessons for tuesday, then wednesday, and then thurdsday and so on. Each list of lessons for a day has a blank row underneath to separate it these rows from the next day.
But then a lesson gets shifted to tuesday and so i hafto add a new row for this new lesson, but that row gets placed at the bottom (ie under "thurdsday"). So it be great to be able to move it up into where all the tuesday classes are (if its at all possible).. that would be awesome!

Also i think it may be an issue, but in this latest 4.7 installation i click on a button next to a column called "column"(?) which takes me to a delete column page (which is what i want to do). It then asks me to confirm if i want to delete and lose all data in column. So I click "delete" and it goes back to the edit table page... but the column is still there! I just cant seem to delete it,

Thanks in advance!
-S

pobster’s picture

Sorry only just read this, well... I'm completely confused by what you're asking... :o( I can't picture in my mind what it is you're trying to do? Could you take a screenshot of your table (or link to it if it's public?)

I'm thinking that you're asking me to do a *simple* 'move up' 'move down' shifty thing (technical term) for the rows? If you are... Well... I'm afraid I tried to do that not long ago and failed miserably :o( I could give it another go, but the logic of it makes my mind boggle... You need to know the ID of the rows above and below according to the sort order... It's not quite as simple as it appears to be! :oS

And thank you for pointing out the bug with column delete - now that's a mystery... :o( I haven't changed anything around that area of the code since I fixed the issue with translations and column delete... Mmmm... I *thought* I tested that release fully? Maybe I didn't... I'll have to reinstall that release and check it out...

An idea just stuck me :oP Bearing in mind that I'm not entirely sure what it is you're trying to achieve... Would it not be better to have your day column as a 'date' data type and change the date settings to show the day of the week (l - lowercase 'L') if you set the date column as the default for sorting then they should fall into order? Hmmmm... After re-reading your feature request I'm not sure that really is what you're trying to do after all...? Maybe I'll wait for that screenshot or link after all ;o)

Thanks

Pobster

rivena’s picture

Hmm... Yes, I think you need to rethink your structure and sorting a little. Moving up and down is tiresome anyway. ^.^

That, or isn't the event module better? Sounds like a schedule thingy you're trying to do...

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 20,000 card scans and counting!
-----------------------------------------------------------

nilamr’s picture

Hi Pobster,

I am a newbie and just learning what can be done with Drupal. I see you have nice module in table manager and seems to be quite popular and the fact that also that you are very receptive to new ideas to for your module is helping people to use it as well!

That encourages me to ask this question - though it may sound like a wild idea on the fact of it.

Is it possible to use table manager to create a page with multiple polls? For example, can I use a cell in a table to insert a poll and next cell have next poll etc. The poll as part of Drupal can function as it is and table manager helps organize and display multiple of those in one page.

Thank you for your attention.

Nilam

pobster’s picture

Wow! That really *is* a wild idea!!! ;o)

Well... It's already possible in a 'hackish' type way (I've just tested this and it does indeed work...) it's not ideal though... Try it and you'll see what I mean:

Install attached_node module
As it's an input filter assign it to 'full html' or whatever you prefer
Create a test table and use the node id for one of your polls as the content of a table cell

In my test case I used:

[node:15]

You'll now have a poll embedded in your table. The reason I say it's not ideal is that using attached_node means you kind of have a 'mini' page displayed rather than only the poll... But then again I guess this is helpful in a way as then the polls title is displayed. Try it and see what you think?

Thanks

Pobster

nilamr’s picture

Hi Pobster,

Thank you for your quick response. I tried this today... I can see the table and other entries into it but the poll doesn't show up (it shows the text [node:6] instead of displaying the poll which is at node6). I did have add and enable "attached node" module. I tried setting input format to "php" and "full html" and in either case

I tried to set the input type as "text" as well as "URL" and neither of them works. What am I missing!! I was trying this in "admin" login.. so probably I do not need to change anything in the filter area.. do I?

Thanks in advance for your help.

Nilam

nilamr’s picture

Hey Pobster,

I learnt from elsewhere on the forum and pasted this code in a cell

  print node_view(node_load(array('nid' => 123)), 1);

where 'nid' is the node id for the poll and it looks great... i did encounter one problem though. This thing saves the current status of the poll into the table - so when I vote on the poll, and come back to the table, it still shows me the status of the poll before I voted on it.... (essentally means, its not showing me updated poll everytime I look at the table).

Let me know if you have any comment on this and / or [node:id] is better in this case (and ofcourse, how can I actually get it to work!)

thanks for your help;
nilam

pobster’s picture

Hiya,

I think before you probably forgot to enable the 'attached node' filter for an input filter? As well as enabling the module, you also need to set which input filter it's to be associated with.

But... What you've done is fine too I guess - as for my comments on it's behaviour... Well... Not sure tbh... The tables aren't cached so the problem stems from polls module and how you're calling the polls I reckon? I'd try the attached node filter again to see if it makes a difference?

Pobster

nilamr’s picture

and yes, it works - so I guess i read your first instruction too fast and missed the filter part at that time..
thank you for clarifying.

The displaying result problem still stays there. In fact, i tried the php instruction i posted earlier in a page, and that did not have such problem. So, it seems to me that it is table manager where cache issue shows up.

I am doing this all as admin login - and i dont have cache enabled. So, i am confused. Let me know if you could think of soemthing.

Thanks
Nilam

pobster’s picture

Erm, I don't think you understand what I mean by caching... Tablemanager has NO cache - if you look at the filter code it says "case NO CACHE: return TRUE;" this doesn't refer to the caching you can enable for the whole site, it refers to internal caching for pages/ filters. If you were to set this to FALSE then you'll find that pagination and paging won't work because the same (cached) table is displayed every time the code is called. THAT'S the caching I'm talking about...

...Tablemanager can't do anything with the poll modules output as Tablemanager *just* displays what it's given and nothing more. I'm sorry that this isn't working for you, but there's absolutely nothing I can do about it? I'm guessing your problem is how the poll module checks to see who is viewing the poll? Maybe you should add a "print $uid;" to the poll module in the appropriate place and check to see who the poll module thinks you are? If it correctly identifies you then the problem is with how the poll module checks to see if your UID has already posted on that particular poll. If it doesn't correctly identify you then the problem is how you're calling the poll from within Tablemanager. Perhaps (if this is the case) you could try calling the poll display function directly? Just a thought...

Pobster

vabota’s picture

Halo, I just installed this module yesterday n it's very helpful. After i saw all the comment i still confuse how to make multiple pages from the table manager. Should i call this method theme('pager', array(), $length)? I have a 3 columns table. Just a simple table to list members of my website. may be pobster could help me ;)

thx before,
boby

vabota’s picture

Woops my bad, i didn't notice tablemanager setting ^^;

rivena’s picture

Hi! I have a four column table. The 3rd and 4th columns are selection types. I want to insert a text only column in between the 3rd and 4th, but even though I set it as text, and save, it insists it's a selection box and makes me try to put in selection options.

Don't reaaaaaaaally want to put the column anywhere else...

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Sorry yeah that is a known bug, it's because I stupidly made the selection box options 'required' - just stick a space (or anything) in that box and it'll ignore it. Sorry my bad...

Incidentally, apologies that it's all gone quiet on the Tablemanager front. I'm afraid I'm seriously lacking in time at the moment and what time I do get to play around I'm devoting to a rewrite (ready for Drupal 5.0) - don't panic though, you'll easily be able to run update.php to upgrade your existing tables. Part of the *new* exciting features is a 'SUM' cell for numeric columns which will work exactly like a spreadsheet does and auto-update the total on every new row added/ altered. Whilst this is also possible with how the db is structured now, I figured I'd finally make my life a bit easier and lose the serialized arrays ;o) It opens the doors for much easier coding to add new features unlike now where everything feels like a messy hack...

Pobster

rivena’s picture

No worries, as long as there's a work around! ;)

I can't speak to whether it's hackish or not, but if you're not happy with it, then it's good to spend the time improving the code. I remember the hype when cpg nuke came out (I used to use php nuke), but when I actually installed it, all it was behind the pretty package was an ugly hack between the coppermine gallery and php nuke. I hope they've improved it since then! Plus I'm sure it's helping improve your skills a lot! You've already improved it enough for me. :)

One of my goals this week is to try a multi site install (I'm on vacation), wish me luck! ;)

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 22,000 card scans and counting!
-----------------------------------------------------------

Anonymous’s picture

I have a questions about the Selection data type.

Is it possible to make the list of selections links? So when the selected item shows up on the table, it will be a link instead of just plain text. For example, if I have a "Year" category, I tried putting something like this in the selection data type text area:

<a href="2006">2006</a>
<a href="2005">2005</a>
<a href="2004">2004</a>
<a href="2003">2003</a>

But on the table it displays the link next to the category name:

Google">Year

2006
2005
...
rivena’s picture

Another thing about the selection box... I think it remembers the position of the text rather than the text?

So, for example, if I have:

Alice
Tom
Bob

And I change that to:

Alice
Tom
Cherry
Bob

Anything that was bob becomes cherry? I haven't tested it out, it just happened when I added some selection choices (expanding the list of possible problems with the site ;p), but you may want to be careful. :)

Anisa.
I read the Bobbsey twins!

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

Anonymous’s picture

Yes that does happen, I tested it several times, so if you want to add a new item, you have to add it to the bottom of the list (which is a bit weird if you want to have an alphabetical list).

rivena’s picture

>>Add by CSV to an already created table.
>Didn't I already do that one?

Did you? I think last time I checked it was for a new table, but maybe that's changed, I never use it myself. :)

>>Duplicate table, duplicate entry, duplicate column.
>Yep - current CVS has duplicate table which works nicely but hmmm... duplicate entry/ column? I think >that may be a bit overkill? I'm not sure whether it'd make the GUI a bit too ... busy? What do you >think?

Duplicate entry, certainly not. You could add a little 'duplicate' next to edit in the table view.

Think of it this way. You have Product X, Brand Y, details, Color: white. Now you just want to add another color, blue. Be a pain to type in everything.

A duplicate column... maybe that might be too much.

>>More kinds of fields, like node reference or user reference.

>CVS already does this (well... user reference anyway - node reference isn't core), I just stopped >development of the 4.7 branch for a bit while I'm working on the HEAD version.

There are some interesting fields for CCK. Oo, what about prepopulated selection boxes like country or month, and you could customize the actual text how you like it somewhere else?

>>Perhaps incorporate taxonomy, give it more flexibility.
>>A few LESS browser refreshes would be nice...
>>Exposed filters for tables (like sourceforge?)
>>Being able to select different input formats for different fields/columns might be interesting.
>I'm a bit lost with these suggestions? Could you expand on what you mean please?

Being able to tag tables/table entries with taxonomy? Not sure what good it would do, exactly, but it's a thought.

Views is like this too, but there are sooo many clicks, so many browser refreshes! Anyway, ability to add multiple entries would be nice. In Gallery, in the image upload section, it automatically gives you 5 upload slots, and you can click on 'Add more' to add another one, no refreshing, it just appears underneath.

Exposed filters. So, I have a list of tasks (http://www.animecards.org/todo/gallery). I think it would be nice to be able to, with a click, show only 'Add set info' tasks. Or, show only 'Tasks assigned to akai neko'. And equally, with a click, remove those filters. You can do it through php or through your tablemanager filter, but you know, more options for the end user.

Also, an 'Edit this table' when you view the table and have sufficent permissions would be heavenly... And, in the admin menu, when you select a table to edit. That drop down menu would be more friendly if it included the table title with it. I don't even remember the numbers of the tables anymore, and I only have 3. :)

>As always though ;o) VERY much appreciated! Thank you! :o)

:)

It's the least I can do.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

Anonymous’s picture

About new features, here are some ideas:

- The Selection data type can be made into links

- To be able to switch the order of columns after they're created. Let's say I created a table with 3 cols:

Date | Name | Address

Then I realized it would be better to have the "Name" column go before Date, it would save a lot of trouble to be able to simply changed their order (like adjusting the "weight" of a menu item)

- I noticed tablemanager is mostly used to make list-like tables, is it possible to make other kinds of tables? The Tables Filter Module and various WYSIWYG can already do this, however users have complained to me that the Table Filter module is too "complex" and takes too much time, while the tables from text editors just "don't look right." They want to be able to make a table like:
__________________
|___|____|___|____|
|___|____|___|____|
| . . | . . .| . . | . . .|
| . . | . . .| . . | . . .|
--------------------

(the "." is just empty space)

Where they can easily insert names into the first two rows, and be able to insert an image to the bottom row (speaking of which, can tablemanager display images? I haven't tried it yet >.>)

Hope that made sense ^^; I'm not sure if tablemanager's original goal was to just make list-like tables, but it would be neat to have an all-purpose table manager thingy =^.^=

- The filter conflict with extra line breaks, etc. Though I guess that's already been addressed and in the work?

- Be able to control the width of a column for each individual table. It would be great if we can have the option to specify the width of a specific column. If I have three columns where the first two contains very short content (like small numbers or 2-3 letter words), and the last column contains long URLs, it would be nice to be able to set the first two cols to be only, say, 20px wide, and the URL column to take up the rest of the space.

- Something about the URL content type, sometimes I have very long URLs, and it pushes the other columns to the side and even wrap to the next line. If there's only one really long URL, it just makes the table look weird with a lot of empty space. Is it possible that instead of having just one field to type in one's URL, we have two fields, one is the actualy URL, while the other one is the URL to be displayed, so I can set www.thisisaveryverylongurl.com to something like www.thisis...url.com

Thanks! And keep up the good work, I really love your module (and am glad to hear the 5.0 version is in the works). :)

pobster’s picture

Thanks for all the suggestions :o) I'll do my best to take them all on board!

Just so that you know, some things have already been worked on (and completed) already, such as giving links a name rather than using the address as the link. So there's a possibility that some things will be released for 4.7 before I'm finished with the 5.0 version...

Pobster

Anonymous’s picture

Maybe it's just me, but when I try to delete a column, it brings me to the confirmation page that says "Are you sure you want to delete column '#'?" blah blah, after I click "delete," nothing happens, the column is still there. :/

I've tried this several times, is anyone else having the same problem?

pobster’s picture

Uhhhh - yeah, look at the modules issues page, it's been known for ages. Changes to Drupal core broke it and to be honest - I don't know how to fix it cleanly so I'm not going to bother at the moment.

Pobster

rivena’s picture

Really??? I didn't know that. Or if I did, I completely forgot. Oh, well.

My site won't go to Drupal 5.0 until they iron out allllllllllllllll the bugs, and even then... it better be really really shiny!

I really should update my signature... we have 23,000 scans now.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Yeah there was a problem with it which I fixed, then someone complained that it still didn't work and I couldn't work out what was wrong as I'd thoroughly tested it. Turned out to be the patch/ change to Drupal core which restricts pages to only one form ID. This is a major headache for the 'delete column' function as that's how it works! I'm literally puzzled about how to proceed now :o( I know the whole function will need to be rewritten, but meh - I'm not fussed about doing it particularly as like I've said previously, I'm working on a completely rewritten version anyway.

...Which is a point... I'm spending a LOT less time programming now and so I wouldn't hold your breath for a new version of Tablemanager for quite a while yet - probably well past the actual release of the new shiny ;o) Drupal 5.0

Pobster
PS. Yes, change your signature, I can't believe you're sooooooo lazy :oP Hehe ;o)

rivena’s picture

I always do what I don't have to do. If I have to cook, I wash dishes. If I have to go shopping, I stay in. If I have to stay in, I go shopping. If I have to work on *ahem* grad school applications, I work on multi site docs and play with Drupal.

I take it you're on the devel list? ;p Those lazy developers. Maybe I'll make a forum post... I need more help with those docs.

Don't worry, though, I'm not going to be holding my breath for a new table manager. There are new views functions to play with that are loads more fun than finicky modules that add unnecessary code to text fields. ;)

Besides, in about 2 weeks, it'll be 24,000, and I'll have to change it again. ;p

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Ello ;o)

Nah not on the devel list, I was for a while but I got lazy ho hum lol :oP

What help do you need with the docs? I could be persuaded to help... I'm a very helpful kind of guy ;o)

Pobster

rivena’s picture

;) How much do you know about multi sites?

drupal.mystavash.net/node/3

I primarily need the apache conf things from step 3. I don't know enough to sort through the forum stuff, and right now, I have zero time. If you can help, please, by all means do, you can post comments anonymously on the site. If you can't, it's okay. :)

Anisa.
must do 3 page translation in 2 hours.... gah...

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

I'm the multi-site KING!!!! ;o) Yep should be able to write something tonight after work closes...

By the way... I'm interested in the 'PRETTY PICTURE' :oP Would that be of yourself then? ;o)

Pobster

pobster’s picture

Ah I kinda ran out of time tonight... Sorry about that ;o) Will try and find some time tomorrow.

Pobster

rivena’s picture

My picture is actually quite pretty, but my policy is to not let my name (because it's very unique) or my face grace the internet. Pretty successful so far!

Maybe when I get my photo site up you can see it. :)

That is, if I see some of that documentation! ;)

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Wow! It's more difficult than I thought! :oS I think I've discovered that it's much harder to write a 'how-to' than just answer someones query about something! :o( Hmmmm... I tried... Maybe I'll try a bit harder later (I'll look up some things I've written previously on this forum) - do I qualify for a pretty picture yet? ;o)

Pobster

Anonymous’s picture

Hmm yeah, good to hear the "short URL" feature will be in the next version ^^, the main reason I asked about the "delete column" function was because some of my URL's were getting too long and I wanted to delete a row to make space, but it seems everything's getting fixed so it's all good :)

Another featureI was just thinking about the other day, it has to do with sorting. At the moment, if I'm not mistaken, when a table has no "default sort by" role, it'll just sort the rows alphabetically from left to right (from id 1 to id x), and if there is a column selected as the default, say, col 2, then the sort order will start from column to and then column 3 and so on.

Is it possible to manually selected which column to sort by after the default column? Say if I have 4 columns with "Title" as my defaul sort col:

Title--Price--Publisher--Website

At the moment, it will sort Title, then by Price, then by Publisher, but I'd like to sort by Title, then by Publisher.

Also another thing I noticed, when viewing the table in IE, the column that is the default sort col loses its background for some reason, so the other columns will have the alternating light/dark background, while the col that's being sorted by is all white, maybe that's just me though (was looking at AnimeCards and the table looks different in IE as well). But with IE7 coming out soon I don't know what will happen...errr...

rivena’s picture

If I remember right, unless it has changed, you have the primary sort, and then it automatically sorts by the column after that.

My tables look different in IE?? That's what I get for never using it. ;p Oh, well, unless it actually breaks, they can live with it.

By the way, pobster, slight problem with the select by query thingy. I made a mistake, and put in the wrong column. I wanted all rows that had N in the Donated? field, but I made a mistake, and put in the Scan details field. Since there were no columns that started with N there, it should've displayed nothing, but it displayed all the rows that HAD nothing in them. Which is not quite right, is it?

Anisa.
Happy netscape user!
PS: Gumugum, did you ever read the myth series?

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

And... Yes... That's quite strange... I'll look into it...

Thank you! :o)

Pobster

pobster’s picture

If you only have one table then you could alter the sorting function yourself, it's hardcoded to take the field ID and the one following it - it should be pretty evident how to change it;

/**
* Sort function
*/
function tablemanager_sort(&$data, $field, $sort = "asc") {
  // reduce $field by one as it currently holds human friendly numbering - first column should be 0 not 1
  $next = $field;
  $field--;
  $code = array_key_exists($next, $data) ? "if (0 == (\$cmp = strnatcasecmp(strip_tags_c(\$a['data']['$field']['data']), strip_tags_c(\$b['data']['$field']['data'])))) return strnatcasecmp(strip_tags_c(\$a['data']['$next']['data']), strip_tags_c(\$b['data']['$next']['data'])); else return \$cmp;" : "return strnatcasecmp(strip_tags_c(\$a['data']['$field']['data']), strip_tags_c(\$b['data']['$field']['data']));";
  if ($sort == "asc"){
    uasort($data, create_function('$a,$b', $code));
  }
  else {
    uasort($data, create_function('$b,$a', $code));
  }
  return;
} // tablemanager_sort

To be honest with you, although it *may* be quite nice to specify which order they sort in - left to right through columns is the way 99% of people will require... I can't think of a 'clean' way to accomplish it either? I doubt I'll consider changing it I'm afraid...

And erm... Do you mean the *active* column? That's white in both IE and Firefox, in fact that's how it works throughout the whole of Drupal to show which column is being sorted! It's not a bug - it's a feature! ;o) If you wish to make it transparent then you'll need to alter your css... That's another story...

Pobster

rivena’s picture

My scans to be donated list was getting too long! And I wanted to separate it into donated scans (Donated? column = Y), and not yet donated scans (donated? column = N). (TEST page for this http://www.animecards.org/node/257)

so I tried this:

print tablemanager_display(2, NULL, FALSE, array('cellpadding' => '5', 'column' => 5, 'start' => 'N'));
print tablemanager_display(2, NULL, FALSE, array('cellpadding' => '5', 'caption' => 'Scans to be Uploaded', 'column' => 5, 'start' => 'Y'));

It works and it doesn't work. It displays the tables correctly, but they are not treated separately, so if I sort by Donator on the first one, the second one also sorts by donator. Well, they are the same table, behind the scenes, but visually they are separate. 2nd, I want the header to be different for the second one, and I tried caption, but that had no effect. I'm sure there is a way, I just don't know the right code to add.

Additionally, all my edit and add entry links have gone away.... which seems to have nothing to do with the above. I can still see them on other tables, just not my scans to be donated table. :( I can see them in the tablemanager admin view but still not on the page! Wah, bring it back!

Fixed. ;p Dunno why. Changed FALSE to TRUE. Nearly gave me a heart attack... the one table people actually use!

print tablemanager_display(2, NULL, TRUE, array('cellpadding' => '5'));

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Hmmm... Tablemanager 1.69 onwards uses elements to allow separate table to be sorted separately... Which version are you using? I'm *sure* you always use the latest version - especially as I recall you asking about the selection box bug thingy before? That's odd...

Pobster

rivena’s picture

Um. I updated it once, recently, but to say I ALWAYS use the latest version, I don't know about that! Chasing after changes in Drupal and Drupal modules is not how to increase the number of scans on my website. I'll check when I get home.

update: I am amazing, I even put a note 'UPGRADED OCT 1' in the folder. ;) The version is 1.71. Hope that helps.

I just keep expanding my table manager usage! I made another table to keep track of most beautiful set nominations (http://www.animecards.org/node/212).

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

Anonymous’s picture

I just though about something, perhaps it won't be possible, but I'm crossing my fingers:

It's about access control. Right now, each table has 3 (I think) options: Permission for users to add items to table, to edit items on the table, and to edit their own entries. At the moment, all these choices have to be made in the access control page.

Is it possible to move all the access control options of table manager-created tables to another place, or better yet, when creating/editing a table, have the options appear on the edit/add table page?

The reason for this is, currently I'm planning on creating a project, which will result in 150+ tables, and it'd be a pain to edit/manage them all on the access control page, and this is what's currently holding me abck from starting this project.

Just a thought ^^;

pobster’s picture

Well I could possibly add the permissions to the create table page, but surely the access permissions page is where they all belong! ;o) I'll see what I can do...

Pobster

Anonymous’s picture

Thank you soooo much! ^^ *hugs*

rivena’s picture

Don't hug the developer, you might get cooties. ;)

The access control page does suck, but it is the place for permissions.

Another thought is to also include the same permissions as part of the edit table page. Or maybe make a tablemanager only access control page that looks the same.

I personally would like to see permissions for tables grouped by table, not by type. now it's edit, edit, edit, edit own, edit own, edit own. A little hard to see, especially since by the time you've scrolled down that way, you can't tell which role is which. ;p

Access control by table is nice, but hard to manage in drupal. Whenever you add a feature, think to yourself, what would happen if I had a hundred tables?

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

pobster’s picture

Just to note - they're only grouped like that because they're in alphabetical order... That's not something I can change, it's a Drupal thing... To group them by table would be as simple as rearranging the order the words are in, so instead of 'edit any xxxx content' it'd be 'xxxx (edit any)'... Okay the wording makes no sense now, but I'm afraid it's the only way to accomplish grouping by table. If you'd prefer this approach, I can do it?

Pobster

Anonymous’s picture

So do you prefer a seperate permission control page for table, or to put the permission as part of the edit table page?

Personally I prefer to have the permission appear in the edit table page, since having all the permission options on a seperate page, with 150+ tables with 4 options to each table, taking into account that some tables have similar names, it can still be hard trying to locate a specific table when editing its permission, whereas with the permission on the eidt table page, when I create/edit a table, I can check off who gets what permission along the way.

Also if an user notices an error with permission of a table, he or she's going to notify me by sending me a link to the table, so I can simply edit the table to change the error, instead of having to scroll and locate the table in a list of hundreds of tables (it'll probably be 400+ since each table will have 4 different permission options? Yikes!)

Again the main reason I mentioned this was because I'm planning to use tablemanager to manage a feature that'll result in 150 tables, and the thought of having over 400 entries in the Drupal access control page is keeping me from doing it. >.>

rivena’s picture

For most user friendly ness, with the table config is the best thing.

Pobster: re reorganizing the permissions, I can just as easily do it myself, no worries.

Anisa.

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------