I created a new field type: which can list values from the database, that are related to this flexinode type.
It creates a list of links from the database.
Example 1:
- I have a flexinode type 'partner companies', and i would like to list all registered user of the given company on the flexinode page of this company.
In the settings page of this field you set the sql query: for the above you can use:
SELECT u.uid, u.name FROM {profile_values} n inner join {users} u on u.uid=n.uid inner join {profile_fields} p on n.fid = p.fid where p.name = 'profile_companydata' and n.value = %d
(Where you can use %d for the node id of the edited flexinode-type)
Then you set:
- Result column for text output: name
- Result column for link path output: uid
- Link base url (e.g "user/"): user/
(Description option: you can output other data related to that e.g. to that user. It will appear in parenthesis, after his name. For example: his phone number can be shown beside his name)
Example2:
- I have a flexinode type 'Events' and for each event i have another flexinode type 'Events subpage' (that has a flexinode 'numeric' field which contains the nid of flexinode 'Event', to which it is related). Flexinode 'Events subpages' are categorized, eg. term '45' is 'Invitation', other terms are e.g. 'powerpoint presentations', etc...
With this query you can list on the flexinode 'Events' mainpage, all subpages of this given event, which are categorized as e.g. 'Invitation' (term id: 45)
SELECT f.nid, n.title FROM {flexinode_data} f inner join {node} n on n.nid = f.nid INNER JOIN {term_node} t on n.nid = t.nid WHERE f.`field_id` = 32 AND f.`numeric_data` = %d AND t.tid = 45
- Result column for text output: title
- Result column for link path output: nid
- Link base url (e.g "user/"): node/
I know it sounds complicated, please let me know if it was unclear.
| Comment | File | Size | Author |
|---|---|---|---|
| field_databaselist.inc | 4.85 KB | keve |
Comments
Comment #1
Bèr Kessels commentedCan someone review this?