Closed (fixed)
Project:
Table Manager
Version:
4.7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
11 Jul 2006 at 18:30 UTC
Updated:
20 Feb 2018 at 17:58 UTC
Jump to comment: Most recent
Comments
Comment #1
Anonymous (not verified) commentedBeyond simply displaying an outside table I was hoping it might be possible to do something like this:
http://neohangout.com/?q=bookchecklist_notread (I created a test account so you can log in. test123:testtest). This may be beyond the capabilities of Table Manager since it's communicating with another table as for what to display and since it uses checkboxes within the table, which I don't see a way to do currently. If you want to see the code for that page you can go here: http://neohangout.com/files/code_books_notread.txt
Comment #2
pobster commentedYeah you can do that, here's how I just knocked it up in a test table:
Created table with 4 columns - Book (text), Rarity (numeric or perhaps barchart?), Price (numeric) and Read (text)
I only did one entry to test and entered it like this:
Book - 1002 Spells for You
Rarity - 86
Price - 20000
Read -
I marked the input filter as 'full html' and yep it renders a checkbox. If on the page you display the table on you have a submit button then you can 'pick up' the checkboxes in the php code.
Hope this helps!
Pobster
Comment #3
pobster commentedHmmm forgot this strips html code...
Read -
<input type='checkbox' name='1'>Obviously this does mean you'd have to re-input all the code... Else you could just display the source and use notepad to tidy it up into csv and then use the csv import function?
Pobster
Comment #4
Anonymous (not verified) commentedOkay, that's great for the checkbox part, but I'm a little confused by what you mean when you say I'll have to re-input the code. Which code are you referring to? Also, how would I tell the table manager to be reading the outside table?
Comment #5
pobster commentedErm, nope ;o) Afraid by reinput the code I actually meant, reinput the table data... There's no way I can incorporate every single way a table can be created into how tablemanager displays it's tables... You'd need to write a custom function to do that, else you'd need to import the table db into tablemangers db. Is it imperitive to keep the tables in the db they are currently in? Does something else need them to be there?
...If not... Meh, I could whip you up a tablemanager csv file pretty easy enough I guess? Not tonight though as I've got stuff to do before I go to bed, but I could certainly do it tomorrow afternoon?
Pobster
Comment #6
Anonymous (not verified) commentedUm, I'm not quite sure I can do it then. I don't have a single table I want displayed. What I have is two tables in the DB. One never changes (except when I manually add a book). The other stores the a sid and uid. That's how I track which users have read which books. The HTML Table I would be showing would compare the two DB tables and display the book information of each book the particular users has marked as read (the 2nd table only adds the books which have been read...that's what the checkboxes are for). So I have to have the query statement sending what data I want displayed on the html table...since I dont want the entire table.
Comment #7
pobster commentedHmmmm... I'm of the opinion "if it's not broke, don't fix it..." but then I guess it would be nice to allow tablemanager to take control of the static table (the one that never changes unless you add a book) - that would mean you'd have to alter the code though to cope with how tablemanger stores information in its database for the other custom functions you have. It would be nice to do... But so not worth the trouble... It'd only be specific for your use, I couldn't implement it in the module for general public usage and it'd *completely* alter your code as you'd have to deal with serialized arrays and whatnot :o(
It's a shame, but I can't see that it's worth your while doing it tbh... If you want to give it a go, then I'm more than happy to recreate your table as a tablemanager db and email it to you? Let me know (although I'm going to bed now - early start tomorrow)
Pobster
Comment #8
Anonymous (not verified) commentedWell, I kind of wanted to do this because I do think my coding is broken. It seems to use up way more memory than it should be...sometimes the page won't even load for me. I thought if I could have your tables and stuff do what I have mine already doing, it might do it more effeciantly. I don't think it would be a problem for me to put my table into table manager, however, I am not sure how I would do the filtering if I did. I would need the table to compare with the other table and only show books that aren't in the 2nd table. I have this being done already in my coding, but not sure how to apply it with table manager. Is it possible to add filtering to the table?
Comment #9
Anonymous (not verified) commentedmeant to add this to the last post...this is my current query statement to compare and display what I want:
$query="SELECT a.book, a.rarity, a.price, a.sid FROM collector_books a LEFT JOIN collector_books_read b ON a.sid = b.sid and b.uid = $user->uid WHERE b.sid IS NULL ORDER BY $order_by";The ORDER BY would no longer be needed though since your table manager deals with that.
Comment #10
Anonymous (not verified) commentedOkay, I just attempted to put my table into tablemanger through the CVS feature you have...unfortunitly it just crashes tablemanger. I had to go into my databse to manually delete what it did enter. I am assuming this happened since there is so much data trying to be imported at once. It's approx 1500 rows.
Comment #11
pobster commentedHmmmm yeah didn't think of that... Of course, 1500 entries is rather a lot... Still it should have worked though? Did you format the csv correctly? Each entry separated by a comma and each row separated by a newline?
Anyways, the code for displaying the table and then updating the 'linked' db should be pretty simple, something like...:
In the checkbox field you should enter the table entry id so that it matches that entry against your other table. eg. tid = 105 so,
<input type='checkbox' name='105'>I was wondering whether you'd changed your mind about doing this as I noticed that I can no longer go to the page where the table is...?
Pobster
Comment #12
Anonymous (not verified) commentedI didn't really change my mind. Last night my entire site crashed and I believe it was a result of the books checklist. I was pretty sure there was a bug in the coding somewhere because it really lagged more than it should have and originally it had given memory errors. To fix that I had just upped the memory limit from 8 to 20. So I took it down to prevent users from using it and crashing the site again. The problem is I really don't know what part of it is causing this to happen.
Okay as for the coding below, I believe I understand that. Still not sure how I control what the table I am displaying is showing though. It shouldn't display the entire table. It needs to compare that main table with the second one and only show items that they have in common (ie. the user matches and only if the book also exists in the 2nd table).
Comment #13
pobster commentedOkay I've got a plan... How about I create a new content type of 'invisible'? I can incorporate this into the main module as it might be useful to other people as well. You can then call the table by;
And column 5 (the one with the TRUEs and FALSEs in it) wouldn't be displayed to a non-admin user? Maybe I could grey it out or something? This would mean that you could restrict whats display to just the TRUE columns and you wouldn't need a separate table to store the read books any more as you'd be able to keep them within tablemanager itself? Unless your other table did something else as well? If this is helpful, let me know and I'll write it...?
Pobster
Comment #14
Anonymous (not verified) commentedI don't quite think you understand how I need to choose what I display. There is no specific column I don't want displayed. It's certain rows I don't want displayed (well, a column or two wouldn't be displayed either). I need to use a query statement to compare and filter the tables to display only what each specific user who is viewing has read. So basically I need to be able to insert a query like this one:
$query="SELECT a.book, a.rarity, a.price, a.sid FROM collector_books a LEFT JOIN collector_books_read b ON a.sid = b.sid and b.uid = $user->uid WHERE b.sid IS NULL ORDER BY $order_by";Comment #15
pobster commentedAha! Yes you're quite right, whilst I read what you wanted to do I didn't really pay all that much attention to the code itself (it's hard following someone elses code!) Yeah I see what you want to do now and it's not something which can be done in a 'general' way for any users of tablemanager - it will need to be a custom function...
It's however no big deal ;o) A simple matter of copying the main display function (and renaming it, else it'll conflict with the main display function itself!) Then altering its db call to match what you wish to display (pretty simple) - you'd then be able to add the submit/ read button into the function and instead of returning the table as code, change it to call a form using drupal_get_form so you can then use drupals form_submit function to pick up which checkboxes have been checked. It's a far neater way of doing it.
Pobster
Comment #16
Anonymous (not verified) commentedt's however no big deal ;o) A simple matter of copying the main display function (and renaming it, else it'll conflict with the main display function itself!) Then altering its db call to match what you wish to display (pretty simple) - you'd then be able to add the submit/ read button into the function and instead of returning the table as code, change it to call a form using drupal_get_form so you can then use drupals form_submit function to pick up which checkboxes have been checked. It's a far neater way of doing it.
Okay, maybe you could point me a little bit further in the right direction. I look through the tablemanager module, but couldn't figure out what/where the "main display function" was in order to duplicate it. As for using drupal_get_form and drupals form_submit function...never used either so not sure I'll be able to do that. I've tried reading explanation of drupals functions on this site before and can hardly ever understand them. They tend to be written for people who already know what they are doing.
Comment #17
pobster commentedBy 'main display' function I was referring to the tablemanager_display function... Just copy and paste the whole lot and call the new one... Say... tablemanager_display_custom... Or something, then I guess what I'd do is to create a new table data type (checkbox) and use the row id as the checkbox reference. I'd definitely put a submit button in the function and not in the page you call the table from as then you can use (if you use the example I gave above) tablemanager_display_custom_submit... If you simply stick a
print_f ($form);if this function it'll give you a huge hint about what you have to work with.Don't be put off by Drupals api instructions, they're functional rather than helpful and I really don't know anything about php programming myself, but I muddle through it by just trial and error.
Hope this helps
Pobster
Comment #18
pobster commentedComment #19
pobster commented