Drupal

Weird AHAH behaviour

Drupal Module Development - 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?

Drupal Module Development - 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

LimaBike.Org

Drupal Showcase - Fri, 2010-06-11 18:49

Here's my new site http://www.limabike.org While it dosen't deviate from the original template that much, it does show how someone with limited web development experience can get a site up and running with Drupal

Categories: Drupal

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

Drupal Module Development - 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

page title for every node??

Drupal Module Development - Fri, 2010-06-11 16:57

Is there any module for page title for every node???
I got the page_title module,but it is for the content types.But my requirement is page title for each and every nodes..please suggest if any module is there!!!!!!!!!!

Thanks

Categories: Drupal

Strange behaviour of node_save

Drupal Module Development - Fri, 2010-06-11 16:07

Something quite weird at node_save...(my own code will be for sure). I have a module which, amonbg others, means to manipulate its own nodes dinamically. Let's see next chunk

function _ugmgr_add_camnode($camera, $create = FALSE) {
        $node = new StdClass();

        if($create) {
                $node->type = NODE_CAMTYPE;
                $node->uid = 1;
                $node->format = 1;
                $node->status = 1;
        } else {
                $node->nid = $camera['node'];
        }
        $node->title=t('You are watching Camera '.$camera['cid']);
        $node->body = "test BODY will BE :: ".$camera['description'];

        node_save($node);
     .....
}

The very fisrt time I use this function, my new node body it is created as expected but, when I recall it with update intentions ($create = FALSE), the
body never changes at all, it all remains like the very first time.
Being a bit confused now about node_save and overall _node_revision_save, I just debug through mysql, where I found next query as result as my node_save :

UPDATE node_revisions SET nid = 25, uid = 1, title = 'Whatever' body = 'BODY will be=first desc', teaser = '', timestamp = 1276271512, format = 0 WHERE vid = 0

And my node and its unique revision both have nid = vid = 25; Why does the code issue a VID=0 ?

read more

Categories: Drupal

Xperts, please explain arrays inside arrays

Drupal Module Development - Fri, 2010-06-11 15:38

I've been reading alot on this site about module development, trying to teach myself how to develop modules (duh), and it is very confusing to me, it feels like topics either jump all over the place, or I'm missing some knowledge or skill that everyone else has, and I don't :(

I've done the tutorial for "On This Day" example module, which is very simple. Now I'm trying to do some more advanced things, but I'm getting hung up on creating a default theme for a module.

I'm having a problem understanding why data stored as arrays inside other arrays. This is probably a PHP knowledge question, not exactly a drupal question, but I am asking for help so I can understand Drupal better.

in some example code from the Book Module:

/**
* Implementation of hook_theme()
*/
function book_theme() {
  return array(
    'book_navigation' => array(
      'arguments' => array('book_link' => NULL),
      'template' => 'book-navigation',
    ),
    'book_export_html' => array(
      'arguments' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
      'template' => 'book-export-html',
    ),
...etc...

it first creates an array with the key 'book_navigation' and sets it's value as an array, and that array has another array inside of it !

why does it do this?

read more

Categories: Drupal

BlogSpot-like Blog archive block

Drupal Module Development - Fri, 2010-06-11 15:23

Hello all,

I am looking for a Blogspot-like blog archive block for a new blog I am developing. I am aware of the archive view included with Views2, but that only gets me halfway there. Below is basically what I'm looking for:

  • > 2010 (10) [clicking on the arrow collapses/expands, clicking on 2010 takes you to blog/2010 archive page, parens are # of posts in 2010]
    • > March (5) [clicking on arrow collapses/expands, clicking on March takes you to blog/2010/03 archive page, parens are # of posts in 3/2010]
      • Blog post A [clicking on link takes you to post]
      • Blog post B
      • Blog post C
    • > February (3)
    • > January (2)
  • > 2009 (15)
    • > December (9)
    • > November (6)

Hopefully you get the idea. The archive view creates the archive links, but it does not create a collapsible hierarchy, nor put the posts in there. My personal blog (which is sorely outdated!) on Blogspot is here: http://crossward.blogspot.com and I am basically trying to mimic the functionality of the Blog Archive "block" on the right side.

Any idears?

Thanks!
Tom

Categories: Drupal

How to rebuild menu cache in drupal6?

Drupal Module Development - Fri, 2010-06-11 15:21

I am writing a drupal 6, custom module, the page that I am calling in hook_menu is giving me a page not found error or it is displaying empty page without any content.
please tell me how do I clear the menu cache?
lot of forums say that devel module has a link to clear menu cache. but I couldn't figure out one.
Please help me how do I clear Menu cache?
I cant go forward without seeing the page content.
your help is greatly valued

Categories: Drupal

hook_file_download when files are not stored in {files}

Drupal Module Development - Fri, 2010-06-11 15:05

Drupals current file upload system is insufficient for what I need. Rather that writing a module that extends it (the current file upload system will still be utilized to some degree), I found it easier to write a module that creates an entirely new system that utilizes two new tables and allows for a versioning system and the ability to organize the files within a certain directory (www.example.com/documents for this example).

Currently the system uploads, moves, deletes files and creates,moves,renames and deletes directories from within this structure. I have hit a problem with file downloads at the moment. hook_file_download seems to be what I am looking for, but I don't really understand the documentation or how it would work with files NOT stored in {files}.

If someone could explain how hook_file_download should be implemented, or at least point me in the direction of a module that correctly implements it it would be most appreciated.

Categories: Drupal

Adding an edit link (hover preferably) to profile pictures

Drupal Module Development - Fri, 2010-06-11 14:53

I am using imagecache profiles, author pane and panels on my site. Users are having a difficult time figuring out how to update their profile pictures. In a way to make it easier for them, I was hoping to add a link to the profile picture (on the "my account" page) that appears when they hover over the picture that sends them to the upload picture field on the edit profile page. Any ideas on how to do this? I'm not much of a programmer so I was hoping the community could help me out. I've searched all over for some way to do this but haven't had any luck.

Thanks.

Categories: Drupal

Simple form api module question, HELP

Drupal Module Development - Fri, 2010-06-11 13:54

I have build simple module form using form api to upload a txt document.
The txt document then process and convert to pdf document, a link to download pdf is given

here my code


function modulku_menu() {
$items = array();
$items['module/form'] = array(
'title' => t('My form'),
'page callback' => 'modulku_form',
'access arguments' => array('access content'),
'description' => t('My form'),
'type' => MENU_CALLBACK,
);
return $items;
}

function modulku_form() {
return drupal_get_form('myform');
}
function myform() {
$form = array();
// If this #attribute is not present, upload will fail on submit
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['file_upload'] = array(
'#title' => t('Upload file'),
'#type' => 'file',
);
$form['submit_upload'] = array(
'#type' => 'submit',
'#value' => 'Submit'
);
return $form;
}

function myform_submit($form, &$form_state) {
$validators = array();
$dest = 'upload_directory';
$file = file_save_upload('file_upload', $validators, $dest);
if ($file != 0) {
$random_digit=rand(0,9);
$new_file_name=$random_digit.$file->filename;
$dest_path = $new_file_name;
$result = file_copy($file, $dest_path, FILE_EXISTS_RENAME);
if ($result == 1) {
$path= $new_file_name;

read more

Categories: Drupal

Simpletest: Custom cleanup

Drupal Module Development - Fri, 2010-06-11 13:45

I'm writing a test of a function that imports data about users from a .csv file. As usernames are randomly generated for testing, I'm dynamically writing this file based on the generated usernames before uploading it. Naturally, I'm removing it before the test is finished running, but if the test crashes for some reason, the file will be left. Is there a way to specify a custom cleanup routine when someone presses "Clean environment" on the testing page that will delete this .csv file, or something else I can do to cleanly handle this situation?

Edit: I realized the best solution is probably to use php's "tempnam()" function to generate a filename in the /tmp folder to use.

Categories: Drupal

Views - the best part of Drupal

Drupal Showcase - Fri, 2010-06-11 12:07

I think working on Drupal 'View' is the most best part.

Categories: Drupal

How update profile field with ubercart actions?

Drupal Module Development - Fri, 2010-06-11 11:18

Hello.

I made event registration and i use UC Node Checkout and ubercart to make possible registration fee.

And i need to change value one of user profile field (profile_attendance value from 0 to 1) after customer make payment for special product.
I want to use Ubercart actions for this and possibility to execute custom php code if condition is true.

But i absolutelly new to php code for drupal.

Can you help please to write this part of code, please?

Thanks for you help.

Categories: Drupal

Using 2 seperate date-filters in views doesn't give the right output.

Drupal Module Development - Fri, 2010-06-11 10:31

I've post this topic yeserday as a bug, but I don't know this is right. Because of my doubt i post it also in this forum.
My site has Drupal 6.17, Views-6.x-2.1, Date-6.x-2.4, CCK-6.x-2.6, Views-Calc-6.x-1.3 and a lot of other modules.
I use these modules for a job-site.
Now I want to make views for reporting with Views-Calc to show totals after searching with filters from views.
The filters are from CCK-fields > date fields: field_date_submitted and field_date_archive.
Now I want to see in my report al jobs from 2009 except the jobs that are in archive before 2009,
My view to realize has the 2 date-filters exposed
1. everything with field_date_submitted before 01-01-2010
AND
2. everything with field_date_archive after 31-12-2008

But when I search with this view, I see the wrong output, I see: everything in archive after 31-12-2008 even posted after 01-01-2008 and everything posted before 01-01-2010.
The output seems like this:
1. everything with field_date_submitted before 01-01-2010
OR
2. everything with field_date_archive after 31-12-2008

I cannot use the filter with Date(node) and then select the 2 date-fields because they don't have the same dates
When I select the 2 date-fields, I only can choose for:
1. everything with field_date_submitted AND everything with field_date_archive after 31-12-2008
Or the other option is:

read more

Categories: Drupal

Drupal 7 Module Dev - Blocks don't show up

Drupal Module Development - Fri, 2010-06-11 10:18

Heyho,

I'm starting to write a module for Drupal 7 according to the HOWTO here: http://drupal.org/node/206753, which is for drupal 6 though.

I created the .info and the .module file exactly as explained in the HOWTO, except that added
<?php
files[] = modulename.module
?>
in the .info file to make my module show up in admin/modules (as explained here : http://drupal.org/node/785714)

The module shows up in admin/modules and I can activate it. But then on admin/structure/block the block created from the module is not there? Also it is not shown in the DB in table blocks, where, I guess, it shoul go?

Any help?

.info
; $Id$
name = met
description = mydesription
core = 7.x


files[] = met.module

.module (exactly as in the HOWTO)
<?php
// $Id$

/**
* Display help and module information
* @param path which path of the site we're displaying help
* @param arg array that holds the current path as would be returned from arg() function
* @return help text for the path
*/
function met_help($path, $arg) {
$output = ''; //declare your output variable
switch ($path) {
case "admin/help#onthisdate":
$output = '

'. t("Displays links to nodes created on this date") .'

read more

Categories: Drupal

I need to strip out header and left navigation when calling a popup from a function

Drupal Module Development - Fri, 2010-06-11 09:58

I created a module and in that module there is a function that opens up some fieldset in a new window. I want to strip the header and left navigtion that is being shown along with the body in the popup. How can i do this?

Categories: Drupal

Multiple forms on page, submit with ajax?

Drupal Module Development - Fri, 2010-06-11 09:49

I'm trying to build a module wich allows for a page and all it's translations to show right next to eachother on a form for easy translating(instead of going page by page).

However, I was thinking, what of instead of building my own forms, I just load the node edit/save forms next to eachother. This would require less code, however each form would have it's own submit function, wich takes you off the page and brings you back to wherever you came from.(Kind of like the Easy translator module, only with pages-translations being seperate nodes in this case.)

Is it possible to execute the submit function through an ajax request? How much trouble will I be in since the form for each node uses the same kind of id's and such?

Thoughts on this?

Categories: Drupal

How can I upload images with my article at top ?

Drupal Module Development - Fri, 2010-06-11 08:52

I have seen so many sites, they upload their images with their articles at top. But, whenever I do this with my blog it also adds one more same image with different url, why?

Categories: Drupal