Is there a way for me to add a custom field to show in the Tables API table uc_product label? I would like to show a custom CCK field in the table as well.
Thanks~
|
UbercartOne cart to rule them all... |
|
| Donate to Ubercart | Affiliates | ||
Custom field(s) in uc_product_table
Submitted by setfree on Wed, 02/13/2008 - 14:03
Is there a way for me to add a custom field to show in the Tables API table uc_product label? I would like to show a custom CCK field in the table as well. Thanks~
I guess so, but it says I have to add code to the module. Does that mean to add one field to the table I have to hack a module? If so, which one??? No, you don't hack a module, you create your own module, which can hold this and any other customization you want. It's really quite easy, less than 10 lines of code - here's a little tutorial I wrote: http://www.ubercart.org/comment/8749/Re-Removing-SKU-product-edit-page Thank you for your help! I have followed your instructions and made a module. The new field should up in the Tables API settings. I enabled it. But the value does not display when the table is rendered, only the new label. I suspect it is in the portion of the extensible tables code: case 'data':I do not know what to do with this part. Here is the code in my module: <?phpAny ideas on what I need to put in there? Thanks again for your help! $data holds the values for your column. Instead of 'score' you need to use your column name, 'field_exterior_length', and instead of assigning it to the fixed array, you need to build an array with your values. If you're storing the values in a CCK field, iterate over the products and extract the value of those CCK fields then put them in the array. You should also change the name of your function to yourmodule_table_alter(). Thank you so much for your help so far. I have been trying in vain to implement the new column as you explained, but have so far been unsuccessful. I do have a little bit of a programming background and tend to be able to figure things out myself - but not this time.
I have tried to do the above - could you please explain further on the code that I need after $data['field_exterior_length'] ? Again, thank you kindly for your time~ Is this close? case 'data': It doesn't display anything, I was just wondering if I'm on the right track? I'm also stuck at this same step, anyone solve this one yet? <?phpThat is what I have in my module and http://www.queencitybeats.com/catalog/1/club_beats this is what displays. Hi, you have missed undocumented third parametr of the hook_table_alter. This parameter is an array of arguments somehow needed to extend the table. Example: Extending uc_product_table with two columns from custom table print_r($args) of the uc_product_table arguments: ArrayIn this case I can load additional data by parsing 'nids' array: <?phpThis tapir feature is not well documented, I learn it by code research. I hope it helps someone. Happy ÜberDrupaling wojtha, Thanks for the example. That was just the info I needed. The fact that the official example was missing the third parameter had me really confused. Aye, thanks for sticking it out and helping wojtha. I updated the documentation for now. It seems the link for Download tapirtest.module is broken in this page: TAPIr: Learn by Example. Could anybody fix this? I had already added a custom field to the uc_product table by using attribute module(an indirect way). Now I need to add another custom field only visible for system administrators, but the accessibility(or visibility) of attributes added by attribute module cannot be configured. Seems altering the uc_product table directly -- in the way discussed in this topic is the solution. Anybody can give me a further suggestion? Thanks.
|
|
Joined: 12/16/2007