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

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!

Is paypal_framework working in 4.6?

I see a number of posts and requests for help ending about March 2, 2006
nodes 46736 51181 16199 and several others

FYI: I am adding a simplified version of it to a 4.7 site I am building. I will be automagically charging pre-existing accounts in the background, without any administration forms, and without (much) user input, though i could update the admin forms to 4.7 style later.

Any help, suggestions, info would be welcome. I'll share my code if anyone wants it when it works.

Thanks, John

Using Drupal for web application

I’m evaluating Drupal for web application development. The tool I currently use is CodeCharge Studio, so I’m actually comparing the two.

For example, with CodeCharge I can write a page that creates, edits, lists and deletes items. All this without writing a single line of code, with every possible validation, without writing single SQL query, by using WYSIWYG editor and all that within 5 minutes. And I would get a fully skinable output, because everything is rendered through one template file. And all the HTML code is in this template file.

On the other hand, today I tried to do that with Drupal. I had to write $form array by hand, write 3 functions that handle form processing (theme_*, *_validate, *_submit), write several SQL statements, and write my logic of processing the functionality of page. I ended up with 2 template files: for form and for page. And at the end I came to the conclusion that I cant make a HTML template just for my table that list the items, cause it’s rendered by using theme(‘table’), which is used for every table on the site, and contains heavy logic. Which is also problem for form elements like buttons etc. Even if I write it again it will take me at least 20 minutes of heavy coding, I will end up with 150 lines of code and I will not be able to skin everything the way I want.

I think that it is crucial that CRUD operations are trivial in order to be productive web app developer.

What is the ImageFrame module?

Gallery2 module's readme.txt says

Requirements
----------------
* Gallery 2.1 CVS HEAD (with ImageBlock and ImageFrame modules installed and activated)
* Drupal 4.7 CVS HEAD (preferably after 4.7beta5 was released)

I installed Node Image Block, but I can's find an ImageFrame module? What can that be?

Pages

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