By betz on
Hi,
For about 3 nights now, i'm trying to figure out how i can use my module-elements in views.
I have a custom mysql-table named nodexperience_node with 2 elements in: nid and nodexperience_value
What i want to do is to have those elements available in views.
1. as a field
2. as a filter
3. as a sorting option
Now i found this handbook http://drupal.org/handbook/modules/views/api but i'm completely lost.
I made a join script that doesn't gives me any errors, but also does NOTHING :)
This is my code:
function nodexperience_api_views_data(){
$data = array(
'nodexperience_node' => array(
'table' => array(
'group' => t('Nodexperience node values'),
'base' => array(
'field' => 'nid',
'title' => t('Nodexperience node values'),
'help' => t("Nodexperience node v experience level of a node"),
),
),
'nodexperience_value' => array(
'title' => t('Experience level of the node'),
'help' => t('Experience level of the node'),
'relationship' => array(
'base' => 'users',
'field' => 'uid',
'handler' => 'views_handler_relationship',
'label' => t('Node Experience')
)
)
)
);
}
Can anyone have a look and say what i did wrong, or didn't do at all?
If i could get thru this, that would be a MAJOR step for me.
Grtz,
tom
Comments
A few things I see. Your
A few things I see.
Your function name is wrong. It needs to implement the hook_views_tables(). The function name probably needs to be nodexperience_views_tables(), depending on the name of your module. You also need to define your join inside the table array. At the end, you will need to return the $data array, otherwise views won't see it.
Try something like this to get started. This should get your table joined and exposes the nodexperience_value field to views.
This code should help you declare the fields for your view. Remember to flush your cache before configuring your view.
Baldwin Louie,
BitSprout LLC
http://www.bitsprout.net
Thankyou for replying to my
Thankyou for replying to my post.
I tried your version, but i still dont get a extra field appearing in my views ui.
I didnt enable caching, or is there another cache for that?
I found the 'flush cache' at
I found the 'flush cache' at the dev module, and indeed i have my element available as a field now.
You made my day. no, you made my 3 last days ;)