Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function webform_options_webform_select_options_info() {
- // get all content types
- $node_types = array_keys(node_type_get_names());
- $items = array();
- // for each of the content types, create an item
- foreach($node_types as $ntype){
- // returns function names as lambda_1, lambda_2, ...
- $callback_func = create_function('', 'return _get_node_titles("'.$ntype.'");');
- $items[$ntype] = array(
- 'title' => t('Node: ' . $ntype),
- 'options callback' => $callback_func,
- );
- } // foreach
- return $items;
- } // webform_options_webform_select_options_info()
- function _get_node_titles($node_type) {
- $options = array();
- $sql = "SELECT nid, title FROM {node} WHERE type = '$node_type'";
- $result = db_query($sql);
- foreach ($result as $row) {
- $options[$row->nid] = $row->title;
- }
- return $options;
- } // _get_node_titles()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement