how to get the pages from a query

Syed_Shah - June 19, 2009 - 18:51

Hello all,
I am in the process of making a module for split testing. I want to populate a combo box with all the pages that have been made by the user (through pages content creation, or any other pages that exist in the drupal website). Kindly tell me what would be the query if i need to bring this data from database. if it could be brought from any other locaiton, kindly let me know. This is highly critical task and requires urgency. therefore a quick response will be really appreciated.

Thanks

Do you really need a combo box?

mradcliffe - June 19, 2009 - 20:41

If it doesn't need to be a combo box form, then you can make all sorts of pages with unique queries with the views module. I highly suggest you use that to come up with dynamic lists of content, users, flags, activity, etc... You can make views into blocks, pages, rss feeds, etc... with output in lists, nodes, tables, etc...

Something like this should work in your form function:

<?php
global $user; // do not modify

$res = db_query("SELECT * FROM node WHERE uid = %d", $user->uid);
while (
$n = db_fetch_object($res)) {
 
// do something with $n
 
$nodes[$n->nid] = $n->title;
}

$form['blah'] = array(
 
'#title' => t('Blah'),
 
'#description' => t('blah'),
 
'#type' => 'select',
 
'#options' => $nodes,
 
'#default_value' => $form_state['values']['blah'], // or something
);
?>

Combo box or list???

Syed_Shah - June 20, 2009 - 10:16

Hello,
Thanks for your suggestion. since it is a split_test, i want to give the user option to chose which pages need to contribute in the split_test, so anything, list etc will work as long as it gives user control to select the pages. HOw can i accomplish it with the view module??

I have one more suggestion. I have been studying tutorials to make modules but am not able to understand much. Actually i want to know, which option appear in the adminsiter (by module). most of the modules have get help, configure permission etc. I want to know which function is control these options. I want to know through which options i can add/delete the links or functions that would appear here in the admin section.

Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.