Needs work
Project:
Data
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Oct 2009 at 03:38 UTC
Updated:
9 Feb 2012 at 15:48 UTC
Jump to comment: Most recent file
A client of mine is wanting to take some of the data that he has imported into his data_tables and reference it from nodes. Anyone have any ideas of how to accomplish this? Originally I was thinking to just use node_reference, but since they aren't actual nodes it won't allow me to select it under the "views" section on the CCK Field (which makes sense). Anyway, if someone has any ideas then that would be appreciated!
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | data_cck.0.3.tar_.gz | 8.13 KB | phayes |
| #18 | data_cck.0.4.tar_.gz | 8.1 KB | jbrown |
| #14 | data_cck.tar_.gz | 8.08 KB | jbrown |
| #14 | data_cck.diff | 12.99 KB | jbrown |
| #8 | data_cck.tar_.gz | 7.5 KB | phayes |
Comments
Comment #1
alex_b commentedTake a look at data_node module (ships with Data). You can use data_node to reference single records in a data table from a node. data_node comes with a views field that provides the interface (add record/remove record from node) and a views data definition that declares the join between the node and the data handler.
It is not yet very well documented, if you wrap your mind around it, I would appreciate some documentation as contribution : )
Comment #3
amariotti commentedCan I get some more information from you about your answer? I'd like to use it similar to the way the node_reference module works as a CCK field on the node creation form for one of my content types. If I wrap my head around it I'd like to create some documentation for this module.
Comment #4
phayes commentedThe current functionality is a little different than what the OP intended I think. Currently you can 'hard-code' a connection between a node and a data row, but it does not allow, for example, a user to select a data-row on the node-editing page (as far as I can see).
I would suggest the following, which should be rolled out as a new module, but might be packaged in with the Data module tar.gz
SELECT DISTINCT column1 FROM table).SELECT DISTINCT column2 FROM table WHERE column1 = whattheyselected).Geomemes is willing to code this up, and will be submitting patches here as we go along, but we would love some input from the Data module maintainers for any suggestions, ideas, and/or code review.
Thanks!
Comment #5
batje commentedsubscribe
Comment #6
phayes commentedJust an update: We are almost done a first release of this which we will post here for peer-review in the next couple of days.
Comment #7
batje commentedWe would be very interested in helping testing.
Comment #8
phayes commentedOkay - here is a first cut. Peer review is welcome.
Some issues we ran into:
1. To properly reference a data-record, there needs to be an ID column in the table to uniquely identify which data-record we are referencing. We allow the user to select any field that looks unique. It would be handy if users had an interface for adding an auto-increment column for data tables that don't have a unique identifier
2. Some JavaScript was needed on the field settings page to make sure that the fields available to select are in sync with the table being selected.
Some things we haven't yet done:
1. Good formatter options. Right now we are just displaying the value of the reference field
2. Views integration. We basically have the interface to uniquely reference a data record, some work needs to be done so that this can be used as a view relationship
You'll note that we did alot of work to get a cool hierarchical select widget - this was because of the use case we need this for. A normal select widget is also included - more widgets might also be useful.
It would be great if the module maintainers were to have a conversation and decide whether they want to host this module as part of the data module package, or if I should start a separate project.
Cheers,
Patrick
Comment #9
phayes commentedComment #10
jamielennox commentedsubscribe
really wanting this functionality. Similarly a link user to data row but hopefully this and content profile can handle that.
Comment #11
phayes commentedjumentous - it should work with content profile - please download and give it a whirl and provide some feedback on any changes you would like to see.
Comment #12
jamielennox commentedOk, had a quick play (haven't gotten to views yet).
Quick remarks:
- There is no None option even when required has not been set
- I don't like the "Add another" multiple selection style, emulating node_reference with a multi-select is much nicer
- When i set the option of 'User Select Field' it works fine, however when i go back and configure the field it doesn't reload my old value and so i have to keep re-selecting the field i want to show
- CCK Referential Integrity integration would be nice when you have time
Mind you i definetly think you have something useful here. I'm sure i don't understand data_node but its a pain in the arse and impossible to work with.
Comment #13
phayes commentedThanks for the review jumentous, I try to squish those bugs. I personally like the 'add another' functionality, perhaps we can put an option in to allow for both. Note that no views integration has been done yet.
P
Comment #14
jbrown commentedI added the autocomplete functionality.
Needs some polish.
There is no access control on the callback.
Comment #15
Robin Millette commentedcount me in!
Comment #16
phayes commentedHere's an update that correct a few bugs:
1. Limits to 10 records on the autocomplete - I have a table with ~160,000 records - it was bad news
2. Added support for strings as referencing fields
As far as I know this is what needs to happen to this thing before it's ready for prime time:
1. Fix the JS on the admin page. The javascript basically takes the 'referencing field' and then filters client-side the available fields on that table. To be even more confusing, the 'reference field' is in the global settings, which sits BELOW the field-specific settings - which is confusing. Perhaps we should hook-form-alter it so that, in this case, global setting sit above node-specific settings. Or someone else needs to think up a better way of handling this. :-)
2. There is no None option even when required has not been set. Select widget.
3. Better formatters. We are just using the reference-field. Yuk
4. Views integration so we can actually add a relationship to the data-table.
5.
Access Control check on the autocomplete widget.Comment #17
phayes commentedComment #18
jbrown commentedI implemented an access check for the autocomplete widget.
Comment #19
kbk commentedUsing module data_cck.0.4 gives me errors when configuring the cck field:
The first two warnings occur for every table I have that is managed by the Data module. I think this is related to the fact that I use a table prefix but, alas, my lot in life is that of a lowly tester not a programmer.
Comment #20
joachim commented> I think this is related to the fact that I use a table prefix
Sounds likely. AFAIK data module doesn't handle table prefixes well anyway.
Comment #21
joachim commentedLoads of functions are missing docblocks.
Comment #22
alexmc commentedHas any of this made it into the D7 version of Data/Data Node?
Comment #23
joachim commentedNope, but given that on D7 you can treat your data rows as entities, you can refer to a data row with Entity Reference module.