This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Things to know when making your own forms

... That took a while to find!

OK, some lessons include:

Avoid and declare Globals

Occasionally some of the libraries set global variables, some of with are then used by other libraries. This is of course to be avoided, doubly so now we are in a Drupal context where there's lots of overhead going on.
ALL GLOBALS MUST BE DECLARED EXPLICITLY at the top of the file (as sometimes we are running inside an eval() and file scope variables may not be global scope.

ALL GLOBALS SHOULD USE A NAMESPACE to avoid possible conflict with the environment.
global $param;
should be
global $MYMODULE_param;
... everywhere.

Beware of reserved parameters

You should not declare form parameters called:

  • q
  • destination
  • edit

unless you are intentionally messing with the Drupal functioning.
There may be more on this list - even modules may add some - can someone publish them?

Image module, simple question!

Hey all, just a simple question for all the developpers that i saw on a lot of Drupal websites.

How do you do to make the image module, so that when you click on "View original" that it displays the original image in a new window...? instead of putting the image in the whole frame... and even better could we be able to customize the new window, and instead of having a "view original" link could we just have the user click on the Preview image and that would open a new window with the wallpaper?

Thanks alot in advance for your help!

taxonomy_select_nodes() not working if 'administer nodes' not set

I've run into a very bizarre bit of improper functionality that I've not been able to track down. I am trying to get a list of all nodes in a given vocabulary, grouped by their taxonomy terms. Seems reasonable, and I've done it before. Here's the code:


function _resource_list() {

  $resources = array();

  $terms = taxonomy_get_tree(5, 0, -1, 1);

  if ($terms) {
    foreach ($terms as $term) {
      $nodes = taxonomy_select_nodes(array($term->tid), 'or', 0);
      $node_list = array();
      while ($resource_node = db_fetch_object($nodes)) {
            print "Found a node!";
	    $node_list[] = $resource_node;
      }
      print_r($node_list);
  }
}

(Plus various return stuff, but I'm trimming out everything not related to the problem.)

If the current user has 'administer nodes' permission, then the print_r() call spits out an array with the correct nodes in it. If the current user does not have 'administer nodes' permission, then $node_list is empty. taxonomy_select_nodes() and db_fetch_object() don't check user_access() anywhere, though.

All nodes in that category are of type "resource" (a custom node type). The hook_access() for that node type is trivially simple:


function resource_access($op, $node) {
  global $user;

 print "<pre>Op: $op</pre>\n";

 return true;
}

According to the print statement, though, it's never being called anyway (as it shouldn't be).

Python and Drupal?

Hi, I'm wondering if there is a way to develop Drupal modules in Python. Thanks.

Need to create nodes from my module (programatically)

I´m using i18 (drupal 4.6) traslations and I need to create page nodes from my module. I´m still getting in touch with drupal, so if anyone can give some API gidelines I might finish.

Best module for creating embedded image in a node? FckEditor?

What's the best module to create nodes with embedded images, not an image attachment? I've done a search but all the discussion seems to be dated back to March~May. In FckEditor there is a built-in image uploader/browser, but that doesn't seem to work. How do I get it to work, ideally with filemanager framer work, as I don't reuse images among posts, and uploaded images should be associated with _THAT_ post only.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions