Révision 7942932f
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/sites/all/modules/votingapi/API.txt | ||
---|---|---|
97 | 97 |
} |
98 | 98 |
} |
99 | 99 |
|
100 |
An example of advanced Views integration |
|
101 |
======================================== |
|
102 |
VotingAPI provides Views Relationship connections for votes cast on nodes and comments. If your module casts other types of votes that should be made available via Views, it needs to implement hook_votingapi_relationships(). |
|
103 |
|
|
104 |
|
|
105 |
function mymodule_votingapi_relationships() { |
|
106 |
$relationships[] = array( |
|
107 |
// 'description' is used to construct the field description in the Views UI. |
|
108 |
'description' => t('nodes'), |
|
109 |
// 'entity_type' contain the value that your module stores in the voting |
|
110 |
// api 'entity_type' column. 'node', 'comment', etc. |
|
111 |
'entity_type' => 'node', |
|
112 |
// 'base_table' contain the name of the Views base table that stores the |
|
113 |
// data your votes apply to. |
|
114 |
'base_table' => 'node', |
|
115 |
// 'entity_id_column' contains the name of the views field that represents |
|
116 |
// your base_table's primary key. This column will be joined against the |
|
117 |
// voting api 'entity_id' column. |
|
118 |
'entity_id_column' => 'nid', |
|
119 |
// VotingAPI constructs pseudo-tables so that multiple relationships can |
|
120 |
// point to the same base table (normal and translation-based votes nodes |
|
121 |
// for example. These two columns allow you to override the names of the |
|
122 |
// pseudo-tables. You probably don't need to change this part unless you're |
|
123 |
// nedjo. |
|
124 |
'pseudo_vote' => 'votingapi_vote', |
|
125 |
'pseudo_cache' => 'votingapi_cache', |
|
126 |
); |
|
127 |
return $relationships; |
|
128 |
} |
|
129 |
|
|
130 | 100 |
An example of a custom Views value formatter |
131 | 101 |
============================================ |
132 | 102 |
VotingAPI's Views integration can present vote results as simple numbers, but most users will want to see something a bit snazzier. By implementing hook_votingapi_views_formatters(), you can expose a custom formatter for any given VotingAPI view field. For the View field that's passed in, your hook should return an array of key => value pairs, where the key is a the name of a callback function that will format the values from the database. |
Formats disponibles : Unified diff
Weekly update of contrib modules