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

mediumvote update

I have just committed a new version of the mediumvote module to CVS. I have added the ability to set voting criteria for individual node types and have beefed up the settings page. I also corrected some minor issues with browsers handling of the ajax voting and addressed issues reported in the module tracker. If you are using the module, I suggest taking a look at the newest version.

As always, I would appreciate any feedback or suggestions.

A big thank you to addictedtotravel.com who suggested and funded the additions included in this release.

Jim

Simple example module which doesn't work

For me, the following example doesn't work (4.7 rc3). Could someone explain what I'm doing wrong?
Thank you in advance.

<?php
function example_form($example = '') {
$form['example'] = array(
'#type' => 'textfield',
'#title' => t('example'),
'#default_value' => $example,
'#size' => 20,
'#maxlength' => 1024,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Verify'),
);

$form['#method'] = 'post';
$form['#action'] = url('example');

return drupal_get_form('example_form', $form);
}

function _example_all() {
$edit = $_POST['example'];

$example = isset($edit['example'])? trim($edit['example']): '';

$output = example_form($example) . '
example:' . $example;

return $output;
}

function example_help($section = '') {
$output = '';

switch ($section) {
case 'admin/modules#description':
$output = t('Example module.');
break;
}

return $output;
}

function example_perm() {
return array('execute example module');
}

function example_menu($may_cache) {
$items = array();

if($may_cache)
{
$items[] = array('path' => 'example',
'title' => t('example module'),
'callback' => '_example_all',
'access' => user_access('execute example module'),
'type' => MENU_SUGGESTED_ITEM);
}

return $items;

Music Module Idea

I've started to use drupal with a "band" I'm in (not really a band, just a musical group), and I've noticed a lack of functionality for audio albums and such that common bands might use. If time permits, I'm going to develop an all around music site module, while trying not to overlap with other modules. I won't be able to start right away, but I'm just trying to get some ideas down right now. I've created a quick diagram.

-------------------------
|        Album          |
| --------------------- | =====> List/Search by Band, Genre
| Title (of album)      |
| Band (optional)       |
| Length                |
| Genre                 |
|                       |      ---------------------------
| Track Listings      ------>  |          Track          |
|                       |      | ----------------------- |
-------------------------      | Lyrics                  |
      |                        | Author                  |
      |                        | Upload audio file       |
      |                        |    (using audio.module) |
      |                        ---------------------------
      v
  ------------------------
  | Reviews (probably    |
  |   handled by         |
  |   another module)    |
  ------------------------

I'm aiming to create something similar to another program I've created, LySite. I may be overlapping a few modules; I tried to mention the ones I knew of, but feel free to mention ones that might cover anything. There is a discography module, but that didn't seem to do near enough.

A hack of directory.module producing "warning: Cannot modify header information"

I tried to fix the directory.module so that it would actually work properly (please note I renamed it to category.module), but I still am receiving this problem on Drupal v4.6.2, I searched on Google and in the forums, and kept finding the same suggestion to look for extra whitespace or other characters before <?php or after ?> here is the error message:

warning: Cannot modify header information - headers already sent by (output started at /home/path/drupal/modules/authors.module:1) in /home/path/drupal/includes/common.inc on line 192.

Line 192 on common.inc seems to be redirecting the current page, this error shows up when I submit any type of form on drupal:

header('Location: '. $url);

Here is the modified category.module (previously directory.module):

<?php

/* $Id: directory.module,v 1.5 2005/09/26 18:05:31 mathias Exp $ */
/* Authored by Matt Westgate */
/* Original Frontier implementation by John VanDyk */

/********************************************************************
* Drupal Hooks :: General Overview
********************************************************************/

/**
* Implementation of hook_help().
*/
function category_help($section = 'admin/help#category') {
switch ($section) {
case 'admin/modules#description':
return t('Create a category of resources based on node metadata.');
}
}

/**
* Implementation of hook_menu().
*/
function category_menu($may_cache) {
$items = array();

if ($may_cache) {
$items[] = array('path' => 'category', 'title' => t('Categories'), 'callback' => 'category_page', 'access' => user_access('access content'));
$items[] = array('path' => 'category/term', 'title' => t('Advanced category search'), 'callback' => 'category_term_page', 'access' => user_access('access content'), 'type' => MENU_CALLBACK);
$items[] = array('path' => 'category/random', 'title' => t('Random category link'), 'callback' => 'category_random', 'access' => user_access('access content'), 'type' => MENU_CALLBACK);
}

return $items;
}

/********************************************************************
* Drupal Hooks :: Core Hooks
********************************************************************/

/**
* Implementation of hook_settings().
*/
function category_settings() {
$output = '';

if (function_exists('taxonomy_help')) {
$vocs[0] = '<'. t('none') .'>';
foreach (taxonomy_get_vocabularies() as $vid => $voc) {
$vocs[$vid] = $voc->name;
}
}

foreach (node_list() as $type) {
$nodetypes[$type] = node_invoke($type, 'node_name');
}

$output .= form_checkboxes(t('Which node types should not be listed in the category'), 'category_no_nodes', variable_get('category_no_nodes', array()), $nodetypes, NULL, NULL, TRUE);
$output .= form_select(t('Which vocabularies should be displayed on the category main page'), 'category_vocabularies_root', variable_get('category_vocabularies_root', ''), $vocs, t('The vocabularies that will visible at the root level of the category page.'), 0, TRUE);
$output .= form_textfield(t('Resource count threshold to display subcategories'), 'category_cat_res_count', variable_get('category_cat_res_count', 10), 5, 6, t('If a category has fewer than this number of resources, the category will try to display the resources available in subcategories.'));
$output .= form_textfield(t('Number of resources to display for each visible subcategory'), 'category_subcat_res_count', variable_get('category_subcat_res_count', 5), 5, 6, t('If subcategories are visible, how many resources for each subcategory should be displayed?'));
$output .= form_textarea(t('Explanation guidelines'), 'category_help', variable_get('category_help', ''), 70, 5, t('This text will be displayed at the top of the category pages. It is useful for helping or instructing your users.'));
return $output;
}

/********************************************************************
* Module Specific :: Public Functions
********************************************************************/

/**
* This is the Controller for category viewing.
*
* Note the menu system will take care of passing in the $tid, which is the
* unique ID of the category requested for viewing.
*/
function category_page($tid = null, $filter = null, $fid = null) {
$output = '

'. variable_get('category_help', '') .'

';
if ($tid > 0) { //Display a category view
category_set_breadcrumb($tid, 'Home');
$output .= category_display_category($tid);
$output .= category_display_resource($tid, $filter, $fid);
if (!$output) {
$output .= t('

There are no resources to display in this category.

'date' form element and node preview

In my node form I have a 'date' form element. Its value is converted to a unix timestamp in hook_submit and saved to the database. In hook_view the date is displayed with format_date().

Up to this point everything is fine.

But if I want to preview the node I get an 'Unsupported operand types' error, because my $node->mydate field is still an array containing day, month and year as separate elements which format_date() does not like.

Is there an equivalent of image.module for Flash?

Very quick question (I think searching the forum has answered this, but just in case I missed something...)

At the moment I am coding script in to my pages by hand to display flash material, but I wondered if there was anything along the lines of the image module that would allow a file to be uploaded. That way I can let Drupal's file handling keep track of files that are in use, rather than FTP'ing them by hand.

I can't find anything on these lines from a search.

Thanks!

Pages

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