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

Q: Can't upload images from my module

I have been trying to allow my module to upload images for the past few days and am getting very frusterated. I was reading through this thread: http://drupal.org/node/53621 and everything I'm doing looks to match this exactly. Since I still havn't been able to get it to work, I tried copying the code from the image.module directly into my module. (I can upload images correctly through image.module).

Right now I am only focusing on getting the hook_update part to work.

I have the following code:

<?php
function surgeon_form(&$node) {
$form['image'] = array('#type' => 'file', '#title' => t('Image'), '#description' => t('Click "Browse..." to select an image to upload.'));
return $form;
}

function surgeon_update(&$node) {
foreach ($node->images as $label => $image) {
$old_path = db_result(db_query("SELECT filepath FROM {files} WHERE filename='%s' AND nid=%d", $label, $node->nid));
if ($old_path != $image) {
//-------------------
//THE CODE GETS HERE AND STOPS. I DONT THINK IT
//HAS ANYTHING IN THE IMAGE VARIABLE
//THE SURGEONS DB_QUERY BELOW DOES NOT
//GET EXECUTED
//-------------------
db_query("UPDATE surgeons set tid = 55 where nid = 29"); //this does not get executed
file_delete(file_create_path($old_path));
db_query("DELETE FROM {files} WHERE filename='%s' AND nid=%d", $label, $node->nid);

Drupal modules extension philosophy

I'd like to know how to create new module's extensions for Drupal correctly?
For example I want to develop my customized forum but based on existing core forum.module logics.
How do I extend its functionality in accordance to my demand?

Do I grab forum functions code to my megaforum.module and change it? Or in what other way I have to do?

Thanks to everyone for attention!

Help with aggregator2 module...

Hello,

I just installed 4.7.2 Drupal on my iste: www.shoppingz.co.uk and I want to use aggregator 2 module ...

E-Commerce Module: Shipping calculated for file Product, when both activated file and tangible product. is this a Bug?

hi,

when i have two different product types: file and tangible. Shipping will calculated for both. but for a file product, no shipping is required. is this a bug, or did I something wrong?

Thanks,
-Jens

hook_menu help/tutorial

Hello all.

I trying to understand how the modules works within drupal. Particularly I am not able to understand how parameters can be passed to a module. In simple PHP page, I used to do this using url. I checked the forum as well as handbook and found that hook_menu can be used for this purpose. But how still remains a challenge for me.

Drupal Vbulletin - working?

Finally got the Drupal vBulletin module working... kinda. It creates users fine in vBulletin database, but for some reason, when logging in Drupal, it doesn't log users in vBulletin. Cookies get created, but no login :(

Anyone else encountered this problem? It's a long shot I'm sure, because this module is kinda new... is it supposed to work? It's at version 0.1 right now...

Pages

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