Get variables from checkboxes.

Hi all,

I'm creating my very first Drupal module (Drupal 7, btw) and I'm almost done with it. There is one last thing and that is that I need to get the values from multiple checkboxes.

My module list certain nodes and each of them gets a checkbox using a foreach $nid. All using the Form API.

Now, when the form is submitted, only one (1) value is returned - and as of now, not even the one that I check, but the last nodes ID.

Perhaps it is because each new value replaces the previous(?). Or something is wring with my code. Someone in the IRC channel told be that the forms checkbox returns an array of the values, but I'm trying to use foreach of that value, without any success.

What could be the problem?
Here is my code - shorted down.


function my_module_cmp($a, $b) {

$a = (array) $a;

$b = (array) $b;

return strcmp($a['name'], $b['name']);

}

function my_module_form() {
$url = taxonomy_get_term_by_name(arg(1));
foreach($url as $term) {
$tid = $term->tid;
}
$term = taxonomy_term_load($tid);
$name = taxonomy_term_title($term);
$terms = taxonomy_get_tree(3,0,1);
usort($terms, "my_module_cmp");
$counter = 0;
$result = taxonomy_select_nodes($tid);
foreach($result as $nid) {
$form[$nid] = array (
'#type' => 'fieldset'
);
// title
$form[$nid]['title'] = array (

Dynamic content metadata

I'm new to Drupal, so this may be a dumb question. I'm looking for a way that a user while editing content would be able to enter a dynamic field and then that field could be edited elsewhere so that all the pages would be updated. For example, in several blog posts one might refer to the number of employees at the company. Rather than putting that number into every post, the user puts in something like [num_employees] and then elsewhere defines num_employees to be 35.

Thanks,
Brad

I dropped my menu_links table...now what

Ok,

So I was having issues with my Primary menu items, so I thought that it might be a good idea to drop my menu_links table from the database.... and now everything is really screwed up.

I did all of this without a backup (groan.... I known....)

I manually recreated a menu_links table in mysql and added columns (based on another install) but things are really screwed up.

Is there a way to "re-create" the default menu tables again, or what is likely the best way forward?

any advice would be appreciated.

404 page not found, can't download files

Whenever I try to direct link to a file or a directory, I get the drupal 404 error. How can I enable direct linking? I can't upload some things via built in uploader because many are bigger than the max size of 7mb that my host allows through the uploader. I've been having to upload them via FTP to a different subdomain just so I can link them!

Storing new Field Type

I'm working on a site that allows clients to get wind measurement data.
Clients subscribe to towers. Each tower has a number of sensors (anemometers, wind vanes, etc) on it.
In this Drupal site, towers and sensors are new content types. Every sensor has a tower_id field (which is a node id) to identify which tower the sensor is on.

The goal is to have, on the "Add Content > Create Sensor" form, a
menu that allows the user to select which tower they want the sensor to be associated with.

I created a module for the new field type "towerfield," which gets all the towers that exist and allows the user to select one. Currently that menu displays perfectly fine.

The problem is that whenever I make a selection from this menu other that the default "- Select Tower -" (no value), I get the following SQL error:

Custom built pager not reloading my search results

I've built a custom search module to get an XML query from an external site. I have to build my own custom pager for it, cause the Drupal one doesn't support my external search. The external search works with a 'hits' and an 'offset' value to determine how many results and which 'page' of results to display. Ex: page one would be hits=10, offset=0, page two would be hits=10, offset=10, etc.

I set up my page to work with a URL like this: "/search/{query}/{pagenum}". I can easily make a link going to the next or previous page by adding or removing 1 from the pagenum in the URL.

Pages

Subscribe with RSS Subscribe to RSS - Drupal 7.x