Drupal

Drupal 6 fails to build menu router and links

Drupal Module Development - Wed, 2010-06-09 16:13

When I enable a new menu in Drupal (for example, mymodule), Drupal should be able to get the menu items from mymodule_menu (hook_menu), process the items and insert the menu items to menu_router and menu_links table.

However, my Drupal fails to do so (it worked well before, according to the previous developer). Each time I enable a module (written by me or modules contributed by others, or core modules), Drupal does not seem to get the new information. The menu items defined in the newly enabled module are not processed and inserted to Drupal's menu system. That means the newly enabled module has no chance to work-- because it's inaccessible.

I did fix this by manually insert the menu item information for the new module into the menu_router and menu_links table and the new menu started working. But this is a nightmare if I have to do this each time I enable a module.

Any one has ever had the same problem? How to fix this?

Thank you in advance.

Categories: Drupal

Adding a AHAH powered form element with AHAH

Drupal Module Development - Wed, 2010-06-09 15:51

Hello masters :)

I hope someone from you can help me a little bit.

I have a multistep form with AHAH enhanced elements (with AHAH Helper). All runs fine.

Now I have to insert a new form element (a select) with AHAH. This is no problem, I render the new form element with drupal_render in the form definition directly in the output of the wrapper-div and build the form element before.

This new element have AHAH functionality too and THIS doesn't function. There is no reaction when I click in the select.

Can you help me please with a hint? Forget I something?

Thank you
Tengu

Categories: Drupal

Can not set default option selected in a select field

Drupal Module Development - Wed, 2010-06-09 15:34

First of all, sorry for posting before in a quite old post (https://drupal.org/node/240783). This new post is related to mentioned one.
I have next field in a form

form['aform']['status'] = array('#type' => 'select',
                        '#title' => t('Status'),
                        '#options' => array(0 => 'OFF', 1 => 'ON'),
                        '#value' => $previousIfExisted,
                        '#required' => TRUE);

The question is that this form is same used to add new records in a db table as for editing existing ones. So If editing, the previously selected value for this
filed should be shown. And so $previousIfExisted will be 0 by default and whichever the previuosly selected.

No way men, I cannot get it working.

Some one said (in older versions of drupal in the above mentioned post) that the options array should be of type

array('OFF'=>'OFF', 'ON'=>'ON');

Where keys and values are the same. :| Actually thrilling if someone's got keys like 'this is my option one'.
Some one knows what am i doing wrong ?

Categories: Drupal

problem with user_external_login_register

Drupal Module Development - Wed, 2010-06-09 15:02

It looks like user_external_login_register use incorrect assumptions about what will happen if you call user_load_by_name for none-existing user name. In modules/user/user.module:2087 we have following code:
function user_external_login_register($name, $module) {
  $account = user_load_by_name($name);
  if (!$account->uid) {
    // Register this new user.
   ...
  }
}

Problem is that for "new user" user_load_by_name will return FALSE.
Correct me if I am wrong, but I think user_external_login_register should be fixed along this lines:

function user_external_login_register($name, $module) {
  $account = user_load_by_name($name);
  if ( $account === FALSE || ( !$account->uid)) {
    // Register this new user.
   ...
  }
}

Categories: Drupal

backporting simple D6 module to D5 (hook_form_alter question)

Drupal Module Development - Wed, 2010-06-09 13:48

Hi,

I've not done much D5 module development, but I need to backport a small D6 module I wrote to D5.

hook_form_alter() has changed. The D6 version has a $form_state variable passed to it that contains the current form state. I've used that to do a little processing and change the value of a webform redirect. Code below. My question is, what's the D5 equivalent of the form_state variable?

read more

Categories: Drupal

Urgent - a simple question about module development

Drupal Module Development - Wed, 2010-06-09 13:35

Hi - I am tasked with quickly knocking up a Drupal module for a client. the module is supposed to provide centralized control of error messages across the site. This is not something I've done before but I'm an experienced PHP dev.

Anyway, perhaps there's something I'm deeply misunderstanding here, but I can't find any standard way to make my module store it's data in custom tables. I've seen plenty of tutorials on the _creation_ of these tables in the module.install file but nothing on actually _using_ them... here's my install file:


function universal_errors_schema() {
$schema['errors_table'] = array(
'description' => t('All error messages are stored here.'),
'fields' => array(
'eid' => array(
'description' => t('ID key.'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE),
'name' => array(
'description' => t('The short name.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''),
'description' => array(
'description' => t('The description of the error type.'),
'type' => 'varchar',
'length' => 1024,
'not null' => TRUE,
'default' => ''),
'text' => array(
'description' => t('The actual text of the error.'),
'type' => 'varchar',

read more

Categories: Drupal

Debugging modules with KomodoIDE causes browser to never complete the request

Drupal Module Development - Wed, 2010-06-09 13:23

I have never been able to get XDebug and KomodoIDE to have the browser complete the request while debugging. If I, say, set a breakpoint, the debugger comes up and I can step and continue to other breakpoints. When I continue past the last breakpoint (or if there are no breakpoints), Drupal seems to run to completion, but the browser never refreshes the window with the result. I then click the stop button in the browser, turn off debugging, and refresh, and the new page displays as expected -- including any redirection to a new page. This obviously slows down my debugging and ActiveState support doesn't know what's wrong.

I have searched drupal.org for a solution, as well as looked at the ActiveState forum.

My configuration is:
WampServer 2 with PHP 5.2.11 (Couldn't get XDebug to work with 5.3.0). Also happens with PHP5.2.9 on my other machine
KomodoIDE 5.2.4
XDebug 2.1.0RC1
Happens with both Firefox 3.6.3 and IE8.0
Happens both on Windows 7 and Vista

Any help or hints or links / search ideas would be greatly appreciated. I *think* this is the right forum, since XDebug is a tool for module development.

Categories: Drupal

Views Bulk Operations - how do I add an operation?

Drupal Module Development - Wed, 2010-06-09 12:54

Hi I am using the Views Bulk Operations module. But I need to include an action to allow the user to download content nodes as an RTF.

I tried to implement my own 'downloads module' with the hook_node_operations like this

/**
* Implementation of hook_node_operations().
*/
function downloads_node_operations() {
  $operations = array(
        'downloads' => array(
        'label' => 'DOWNLOAD',
        ' callback' => 'mymodule_download_function',
        ),
  );
  return $operations;
}


/**
* Valid permissions for this module
* @return array An array of valid permissions for the downloads module
*/
function downloads_perm() {
  return array('access downloads content');
 
}

This option did show in the admin drop-down but was not available in selected operations in my view. Why does this not appear, any ideas (I am logged in as admin user1)?

Thanks
Steven

Categories: Drupal

XML module

Drupal Module Development - Wed, 2010-06-09 12:03

Hey all

Sorry if this is the wrong place to post but I couldn't find a sub forum that seemed to fit my question.

I'm looking for a module that will allow me to display XML data pulled from another website in a users profile and have this as a required field when the user register's on my site. The user would be required to enter a url upon registration which would pull the required XML data from an extrernal site.

Sounds mind boggling but hopefully someone will be able to point me in the direction of a solution. I thought an XML feed module might be what I'm after but a bit unsure if there's something along the lines of a CCK XML displayer?

Cheers for any help.

Andy

Categories: Drupal

Dependency

Drupal Module Development - Wed, 2010-06-09 11:59

I''ve added a dependency to my modue by adding the line dependencies[] = token to my .info file.

However when I try to call the token_replace() or any other token function I get the "Call to undefined function" error from php.

Have I missed something? Have searched for site for a "How To" for dependencies without any joy.

Cheers,

Roy

Categories: Drupal

Query related to jcarousel

Drupal Module Development - Wed, 2010-06-09 11:53

Hi,

I have installed jcarousel jcarousel-6.x-1.1 ,viewscarousel-6.x-2.x-dev modules for carousel effect . I created a view for the carousel with image nodes. currently I have a display of carousel in a block which displays 3 images at a time.My query is I want to display only 1 image at a time and after scroll it should display the next one.(i.e one image display at a time). Anybody has any suggestion to tweak a module so that I get a required display?

Thanks.

Categories: Drupal

About ahah in form

Drupal Module Development - Wed, 2010-06-09 11:27

Hi, about ahah in form. i'm new in this part and i found it really hard to make it work.

Below is the code:
$form['xxx']['yyy'] = array(
'#type' => 'select',
'#title' => t('title'),
'#default_value' => $id,
'#options' => $arr,
'#description' => t('The desc.'),
'#required' => TRUE,
'#ahah' => array(
'event' => 'change',
'path' => 'menu/path',
'wrapper' => 'the-div-wrapper',
'method' => 'replace',
),
);

$form['xxx']['zzz'] = _function_to_get_element($id); // this is also a selection element

The logic is when i select the 'yyy' element, i want to update the 'zzz' element content according to the 'yyy' selection value.

I tried many times, when i change 'yyy' selection, nothing happens. I don't konw why.

Any suggestions appreciated!
Thanks!

Categories: Drupal

Showing view / edit tabs in list of nodes

Drupal Module Development - Wed, 2010-06-09 10:39

I got a page that lists nodes (a list of services, where each service is a node). I now want to add those view / edit tabs above each item, so that if you click the edit tab, you can edit the node right below it.

I know how to add those tabs above a single node that spans the entire page, but am stumped on even figuring out how to start on adding them on a listing. Can anybody shed some light on this?

Thanks!

Categories: Drupal

How to get hook_theme work for two different blocks?

Drupal Module Development - Wed, 2010-06-09 09:44

Trying to add second block for random polls for advanced poll module. Currently it has only one for latest poll. I am trying to add a block for random poll. Have done most of the job, need just a little push further from more advanced coders. Please, see http://drupal.org/node/811762#comment-3067462

Categories: Drupal

Remove the Posts tab in the user profiles

Drupal Module Development - Wed, 2010-06-09 09:34

Hi

I'm trying to alter the tabs in the user profile.

I have added an extra tab by using the hook_menu API and that was successfull.

But I'm now trying to remove the Posts tab in the user profiles by using the hook_menu_alter API. I have no sucess at the moment.

I want to remove the user/%user/posts because I have replaced it by another page with only some specific posts.


<?php

/**
* Implementation of hook_menu().
*/
function node_gallery_custom_menu() {
$items['user/%user/galleries'] = array(
'title' => 'My Galleries',
'page callback' => 'node_gallery_list',
'page arguments' => array(1),
'access callback' => '_node_gallery_custom_access',
'access arguments' => array(1),
'file' => 'node_gallery.pages.inc',
'file path' => drupal_get_path('module', 'node_gallery'),
'type' => MENU_LOCAL_TASK,
);

return $items;
}

function _node_gallery_custom_access($account) {
return in_array('photographer', $account->roles);
}

function node_gallery_custom_menu_alter(&$items) {
// what should I write here to disable $items['user/%user/posts']
}

Br.
Rune Christensen

Categories: Drupal

Trigger module: Programmatically assigning actions to triggers

Drupal Module Development - Wed, 2010-06-09 08:26

Hi, I try to make a module I develop to assign some actions it defines through the hook_action to appropriate triggers. Looking at the documentation, searching the web and looking at trigger module code I didn't find any function for actually assign an action to a trigger from inside a module's code. Studding the code of trigger.admin.inc I came up with this piece of code for doing what I want:

/*Assign actions to triggers. A dirty hack.*/
        require getcwd().'/'.drupal_get_path('module','trigger').'/'.'trigger.admin.inc';
        foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
                if ($action['callback'] == 'mymodule_add_user_action') {
                        $form_values['aid'] = $aid;
                        $form_values['hook'] = 'user';
                        $form_values['operation'] = 'insert';
                        trigger_assign_form_submit(array(), array('values' => $form_values));
                        drupal_set_message(t('MyModule add user action assigned.'));
                }
        }

I really don't like much this "hack". Is there a more straightforward way to do what I want through my module? Have I missed anything? What do you suggest?

Categories: Drupal

I want to change "Group" word to "project" in organic group module, I am using drupal 6.x with postgre.

Drupal Module Development - Wed, 2010-06-09 06:41

Plz suggest me how to customize organic group module so i would use it as "Project" instead of "Group"......!

Categories: Drupal

File Field

Drupal Module Development - Wed, 2010-06-09 06:37

Hi to all,

Can any one please tell me the path where the files will be stored that are uploaded using the file field in CCK form?

Thanks for your understanding,

NIKHIL

Categories: Drupal

how to add enum field using drupal_install_schema?

Drupal Module Development - Wed, 2010-06-09 05:29

Hello friends,

I want to create a table using drupal_install_schema, I have define all fields within schema but now I am not getting how to add enum type fields.
I can create this table by directly using query in hook_install( ) but i would like to do this in drupal way.

Thanks in advance.

Categories: Drupal

Possible to insert nodes through a form?

Drupal Module Development - Wed, 2010-06-09 03:15

Sorry, newbie question.

I've got a form_submit() file in a module I've created. I want to take what's in the $form_state['values'] and insert it into the database for specific nodes.

<?php
function lookingfor_searchform_submit($form, &$form_state){
//I want to take whatever value is available to me (say, $form_state['values']['text_search']) and create a new Story node with that information put into the body field (or anywhere, really).
}
?>

Was thinking of hooking in through hook_nodeapi() but I can't figure out what case operation I would need. Kind of lost, new to programming Drupal.

Thanks for any help.

Categories: Drupal