Drupal Module Development

Syndicate content
For assistance with module development.
Updated: 12 weeks 1 day ago

PHP Exec executes some commands, but not others

Sun, 2010-06-13 11:36

I'm trying to get the difference between 2 files on my Debian system.

<?php
$output=`diff path/to/file1 path/to/file2`;
echo "<hr>".$output."<hr>";
?>

Gives a page with "<hr><hr>".

However, this:
<?php
$output=`ls -la path/to/files/`;
echo "<hr>".$output."<hr>";
?>

Gives me a listing of the directory as expected.

Do the executables need to be registered somewhere?

Categories: Drupal

Shadowbox in Drupal

Sun, 2010-06-13 10:45

Hi all,
I am a novice in using Drupal and currently working hard to get my grips on the whole thing. I've been using the Shadowbox module to handle images within my Drupal site but would like to do the same for audio and video.
This is where I get into trouble: within 'shadowbox options' there seems to be no way to configure for video and mp3, whereas when I configure the 'display fields' for which I want to use mp3 I can't set it to Shadowbox. I can choose from various SB G fields, but they seem to apply to images only.
Does anyone know what to do in this case?

Categories: Drupal

display subtotal,Free shipping,discount,order total preview?

Sun, 2010-06-13 02:17

HI
ubercart shipping cart page?

example:www.example.com/cart
How to:
display subtotal,Free shipping,discount,order total preview?

Thank you very much

Categories: Drupal

db_fetch_object stopped working?

Sun, 2010-06-13 01:10

Okay, I'm very confused. I had this code in my hook_block under the view operation and it worked fine. I decide to put the query in its own function to pretty up the code and it stops working.

<?php
function _module_whatever($delta){
if ($delta == 3){
        $type1 = 'looking';   
        $field_name = 'field_lookingreference';
        $row[] = array('General', 'Specific', 'Description', 'Specific');
       
    }
    elseif ($delta == 4){
           $row[] = array('General', 'Specific', 'Description', 'Specific');
        $type1 = 'offering';   
        $field_name = 'field_offeringreference';
    }
   
    $sql = "SELECT n.nid, t.tid  FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid WHERE n.uid = %d AND n.type = '%s' ORDER BY n.nid";
    $result = db_query(db_rewrite_sql($sql), $user->uid, $type1);   
   
    while($data = db_fetch_object($result)) {
//Never reaches here. For whatever reason, the $data is remaining null and the db_fetch_object is not working.
..}
}
?>

The $data = db_fetch_object($result) is coming up null. I've run dsm($result) and it's given me objects, but the function is not working. dsm($data) is NULL.

So, so, so very confused.

Categories: Drupal

Explain custom fields in D7 vocabulary

Sat, 2010-06-12 20:51

Give some example why would you add custom fields to a vocabulary.
Is it possible to add these fields as a fieldset in a content type.

Categories: Drupal

multipage form not working

Sat, 2010-06-12 15:54

Hi,

I'm trying to build a multi-page form but nothing happens when submit is clicked after the first step.
This is (part of) my code for creating the form.

<?php
function lesplanning_add_form($form_state = NULL) {
//first check user role
global $user;
// Check to see if $user has the docent role.
if (in_array('docent', array_values($user->roles))) {

}else {
//do leerling stuff
if(!isset($form_state)){
$step = 1;
}else{
$step = $form_state['step'] +1;
}

$form['step'] = array(
'#type' => 'hidden',
'#value' => $step,
);

switch($step){
//start of by selecting subject
case 1:
//get subjects from db
$result = db_query("SELECT vak FROM {subjects}");
$options = array();
while($row = db_fetch_array($result)){
$options[] = $row['vak'];
}
$form['subject'] = array(
'#type' => 'checkboxes',
'#title' => 'Selecteer het vak waar je bijles voor wil',
'#options' => $options
);

$form['choice'] = array(
'#type' => 'radios',

read more

Categories: Drupal

Difference between [a/%b] and [a/%] in paths

Sat, 2010-06-12 15:29

Hi,
what's difference between:
$items['a/%']

And this one:
$items['a/%b']

what's usage of writing b after percent?

Categories: Drupal

Book of nodes for customized Proposals.

Sat, 2010-06-12 14:13

I am not sure if I should try doing this in D6 or D7, but thinking that this might be interesting to try both ways.
I want to create a customized proposal system for an Industrial Construction Project. Naturally, we don't want competitors to see what we are doing, but we are also looking for a way to setup formal proposals in a template solution.

We begin with a template, probably a template of a book.

In each book section the author can attach references to other nodes.

The finished Book would be en entire node that we could invite Prospects to see.

Just an outline:
Section Intro, would include an NDA that the client would have to agree with. Just not to show it to competitors.
section one would be a proposal outline with details
Section Two would include all details to qualify to compete on the project.
Section Three would include Nodes of past projects that we have done

I would also want the project to have limited access to just prospects, and probably time limited as well. So we can send an invitation to a prospect to view the project, but no one else except for internal people can view it. Then use time or limit viewing by IP address or something like that.

My thoughts on doing this would include:
- A Single domain, and assign Books to users. But need to get the right Modules for this.

read more

Categories: Drupal

Form in block (D7): Am I wrong or is it a bug?

Sat, 2010-06-12 13:06

Hi,

I want to display a custom form in a block.

My block:
function my_module_block_view($delta = '') {
  switch ($delta) {
    case 'my_block':
      $block['content'] = drupal_get_form('my_module_test_form');
      break;
  }

  return $block;
}

My form:
function my_module_test_form() {
  $form = array();
  $form['any_value'] = array(
    '#type' => 'textfield',
    '#title' => t('Insert a value'),
    '#default_value' => '',
    '#required' => TRUE,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Do it'),
  );
  return $form;
}

Submission code:
function my_module_test_form_submit($form, &$form_state) {
  drupal_set_message("Form submitted");
}

When I try to submit the form, I get an error message because of the execution time is greater than 30 seconds, sometimes I also get a memory error, that the maximum memory (64MB) is too less. If I try to load the form on a single page and disable the block, everything works fine.

Any idea, what there is wrong?

Best regards,
Sebastian

Categories: Drupal

Video not found or access denied: drupal-6.16/sites/default/files/sites/default/files

Sat, 2010-06-12 12:45

Module : SWF Tools 6.x-3-0-beta4.

I have install this module at the local machine (Ubuntu 9.10) with the Apache2 mod rewrite enable and clean URLs configuration. Why the same problem still occur again ? Maybe setting of Apache is wrong ? Windows system not yet tested. I like this module, a lot improvement.

Categories: Drupal

hook_schema / hook_insert versus hook_field_* / drupal_execute

Sat, 2010-06-12 09:43

hi drupal community,
it's very hard to get information and answer about this kind of issue

I want to programmatically populate a new content of my own ( job status extracted from SAP).
But what is the better way to create and also access this new content ?

I think there are many ways

first by directly creating a table in the database using hook_schema and populate with hook_insert

second add field to existing content using hook_nodeapi and hook_insert

third by creating a custom content with cck ( hook_field_*) and populate with drupal_execute

I'm thinking to use the third way for reusability reason.

Hope somebody understand my problem and has an idea about it.

Thanks for any clue

Categories: Drupal

permission and role

Sat, 2010-06-12 09:07

i have created role and assign permission to a newly created user.but when i login it through the newly created username and password the permission which i have not assign to it is also coming. i think it's not working .

Categories: Drupal

Create form using Form API

Sat, 2010-06-12 08:27

Hi all,
I'm having this problem, and want everyone can help for me, the problem following:
I created form using Form API, and i want while calling form then assign value to text filed(because value of text file always change).
Thank all!

Categories: Drupal

Probably a Stupid Question...

Sat, 2010-06-12 07:58

I know this is going to end up being a stupid question, but I have a problem that thus far I have been unable to find the answer to. I have Googled and even tried loading code up into XDEBUG and still can not find what I am looking for. My problem is this...I have a website that I am working on that started off using Drupal. The user database is all based in Drupal. What I am trying to do is tie Drupal's credential system into the pages that I am creating. Now what I do know is that when a user logs into Drupal is creates a PHP session and sets a cookie. This means that Drupal is setting a PHP $_SESSION variable and checking to find out if a user is logged in. What I need to know is what the name of that variable is for standard user and for admin users so I can verify if the user is logged in when they visit my page. At this point I am open to any ideas..

Thanks,

Whit3fir3

Categories: Drupal

Selecting name in taxonomy array

Sat, 2010-06-12 04:10

So, basically, I'm creating a $tmpNode = node_load($nid). I'm then inputting dsm($tmpNode->array). My results are below:

#
... (Array, 1 element)

    *
      3 (Object) stdClass
          o
            tid (String, 1 characters ) 3
          o
            vid (String, 1 characters ) 1
          o
            name (String, 5 characters ) Books
          o
            description (String, 0 characters )
          o
            weight (String, 1 characters ) 0
My question is, I want to simply grab the name value from here.

$tmpNode->taxonomy->name doesn't work, since I'm one level too high for the name. It's in an array within the taxonomy array, titled by my term id ("3 (Object) stdClass"). But I can't figure out how to iterate down through that second array.

Help would be immensely appreciated.

Categories: Drupal

User registration confirmation

Sat, 2010-06-12 03:17

I am trying to display a page after a user has filled in the registration form, where a confirmation message would appear. Are you sure you want to register? Yes / No. User should be created only if the answer is Yes.

I have some code here, that fails to override the core user register submit function.


<?php
function confirm_registration_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_register':
$key = array_search('user_register_submit', $form['#submit']);
if ($key !== FALSE) {
unset($form['#submit'][$key]);
}
array_unshift($form['#submit'],'confirm_registration_user_register_submit');
break;
}
}

function confirm_registration_user_register_submit(&$form, $form_state) {
if (isset($form_state['values']['mail'])) {
return _confirm_registration_confirm($form_state);
}
return user_register_form($form_state);
}

function _confirm_registration_confirm(&$form_state) {
$desc = 'Are you sure you want to register?';
// Tell the submit handler to process the form
$form['process'] = array('#type' => 'hidden', '#value' => 'true');
// Make sure the form redirects in the end
$form['destination'] = array('#type' => 'hidden', '#value' => 'example/todo');

return confirm_form($form,
'Are you sure?',

read more

Categories: Drupal

Need Help with installing / using Google Maps on my site...

Fri, 2010-06-11 21:46

I am a newb Drupal user (3rd day)....wanted to ask for some help...

I am trying to install a Google Map onto my site....and cannot get it to work...here is where I stand:

I found the GMapEZ module, downloaded it, unzipped it, used my FTP to transfer it into my hosting center - drupal/modules...it is there now, I activated the module.

I then went to Google and got me a Google Maps API key....which I then input in the GMapEZ module section...

What do I do now?

What code do I actually use to put into the body of the page in order to get the Google Map to apprear?

I tried to copy various forms of code from other forum discussions, but none of them have worked...definitely need some help here.

(dont know php at all...btw)

Whatever you can do to help would be much appreciated.

Andrei

Categories: Drupal

Weird AHAH behaviour

Fri, 2010-06-11 21:05

I'm building a multistep form with ahah, on the first step, when ahah is called from a button the ahah is working and the form progress to step two, on the step two when the final button is clicked then the ahah is working and reverting back to step one.

the problem is after the new step one is build, the ahah button to get to new step two is broken and doing a full page refresh, but then when the page refreshed and come to step two, ahah is working again when we click the button to call another new step one.

the form code :


<?php
function drupie_multimedia_create_album_form($form_state) {
$form = array(
'#tree' => true,
);

$form['album'] = array(
'#type' => 'fieldset',
'#prefix' => '',
'#suffix' => '',
'#collapsible' => false,
'#collapsed' => false,
'#tree' => true,
);

if (empty($form_state['storage']['step'])) {
// we are coming in without a step, so default to step 1
$form_state['storage']['step'] = 1;
}
switch ($form_state['storage']['step']) {
case 1:

$form['album']['album_type'] = array(
'#type' => 'select',
'#title' => t('Album Type'),
'#description' => t('What is your album type going to be?'),
'#options' => array('image_album' => t('Images album'), 'video_album' => t('Video album'), 'audio_album' => t('Audio album')),
'#required' => TRUE,
);

read more

Categories: Drupal

Can someone tell me the best modules for a directory of vendors who pay a yearly charge for a display section?

Fri, 2010-06-11 20:30

Before coming to Drupal...
I basically built a site with the LOOK I want, but I need the interactivity of Drupal so new Participant vendors can each have yearly-paid access to a pre-formatted set-sized division (think of a directory introducing a growing number of Participant vendors displaying their company splash as you scroll down the page).

I need each Participant vendor to have right of access only to their own pre-formatted "division" so they can upload, say, a 300x300 jpg on the left and some max amount of intro text and / or logo on the right, plus a button linking to their own entire page on the same website where they have tools to set up display with more freedom as they wish, preferably drag and drop for their jpgs and auto-formatting text boxes easy for non-techies.

So each vendor has his own css predefined-look table to add text and photo data to on a front page to keep a fairly uniform site appearance. Each new member's created table/division/whateverdrupalcallsit gets added to the existing scrolling "list" of others, auto-inserted alphabetically by the member-vendor's company name.

This is for a website introducing independent perfumers' fragrance lines, so I need a deep-toned zen-like high-fashion look, not bloggish.

read more

Categories: Drupal

file_save() & hook_file_insert(): Intercept before file is saved to disk?

Fri, 2010-06-11 18:30

Hi

If I read the File API correctly, when a file_save() operation is requested, then a file is persisted to disk and then it file_save()'s associated hook_file_insert() & hook_file_update() implementations are called. Is this correct?

If this is so, then can is possible to prevent file_save() operation writing to disk?

Thanks

Jeff in Seattle

Categories: Drupal