Hi ,

I have just installed Dynamic Display Block and successfully imported both content types and views for embeded videos. I then created content of an embeded youtube video and received this notice "warning: Cannot modify header information - headers already sent by (output started at /.../.../.../.../themes/garland/template.php:1) in /.../.../.../.../includes/common.inc on line 148."

I then created the instance and then the slide show and indicated in the documents.... just to see if the error went away?! no it did not...

What seem to happen now is that whenever I create content when I click save the page goes blank and I have to navigate to another page to get the site back (the data is however saved). This message as written above also randomly appears again?

Any ideas?

Comments

OnthegOinOz’s picture

PS below is my template.php file from the garland theme:

<?php
// $Id: template.php,v 1.16.2.2 2009/08/10 11:32:54 goba Exp $

/**
* Sets the body-tag class attribute.
*
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
*/
function phptemplate_body_class($left, $right) {
if ($left != '' && $right != '') {
$class = 'sidebars';
}
else {
if ($left != '') {
$class = 'sidebar-left';
}
if ($right != '') {
$class = 'sidebar-right';
}
}

if (isset($class)) {
print ' class="'. $class .'"';
}
}

/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
* An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '

';
}
}

/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {
$vars['tabs2'] = menu_secondary_local_tasks();

// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
}

function garland_preprocess_ddblock_cycle_block_content(&$vars) {
if ($vars['output_type'] == 'view_fields') {
$content = array();
// Add slider_items for the template
// If you use the devel module uncomment the following line to see the theme variables
// dsm($vars['settings']['view_name']);
// dsm($vars['content'][0]);
// If you don't use the devel module uncomment the following line to see the theme variables
//drupal_set_message('

' . var_export($vars['settings']['view_name'], true) . '

');
//drupal_set_message('

' . var_export($vars['content'][0], true) . '

');
if ($vars['settings']['view_name'] == 'ddblock_embedded_video') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
// add slide_image variable
if (isset($result->node_data_field_pager_item_text_field_image_fid)) {
// get image id
$fid = $result->node_data_field_pager_item_text_field_image_fid;
// get path to image
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)
if (module_exists('imagecache') && is_array(imagecache_presets()) && $vars['imgcache_slide'] <> ''){
$slider_items[$key1]['slide_image'] =
theme('imagecache',
$vars['imgcache_slide'],
$filepath,
check_plain($result->node_title));
}
else {
$slider_items[$key1]['slide_image'] =
'Only local images are allowed. '" alt="' . check_plain($result->node_title) .
'"/>';
}
}
// add slide_text variable
if (isset($result->node_data_field_pager_item_text_field_slide_text_value)) {
$slider_items[$key1]['slide_text'] = check_markup($result->node_data_field_pager_item_text_field_slide_text_value);
}
// add slide_title variable
if (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = check_plain($result->node_title);
}
// add slide_read_more variable and slide_node variable
if (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', 'node/' . $result->nid);
$slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid;
}
}
}
} if ($vars['settings']['view_name'] == 'ddblock_embedded_video') {
//drupal_set_message('

' . var_export($vars['settings']['view_name'], true) . '

');
//drupal_set_message('

' . var_export($vars['content'][0], true) . '

');

foreach ($vars['content'] as $key1 => $result) {
// add youtube video thumbnail
if (isset($result->node_data_field_custom_pager_text_field_embedded_video_url_data)) {
$data=unserialize($result->node_data_field_custom_pager_text_field_embedded_video_url_data);
//print '

';
          //print_r($data);
          //print '

';
if (isset($data['thumbnail']['url'])) {
$slider_items[$key1]['slide_image'] = 'Only local images are allowed. '" alt="' . $result->node_data_field_custom_pager_text_field_custom_pager_text_value .
'"/>';
}
}
// add slide_text variable
if (isset($result->node_data_field_custom_pager_text_field_slider_text_value)) {
$slider_items[$key1]['slide_text'] = $result->node_data_field_custom_pager_text_field_slider_text_value;
}
// add slide_title variable
if (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = $result->node_title;
}
// add slide_read_more variable and slide_node variable
if (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Play now...', 'node/' . $result->nid);
$slider_items[$key1]['slide_node'] = 'node/' . $result->nid;
}
}
}

$vars['slider_items'] = $slider_items;
}
}
/**
* Override or insert variables into the ddblock_cycle_pager_content templates.
* Used to convert variables from view_fields to pager_items template variables
* Only used for custom pager items
*
* @param $vars
* An array of variables to pass to the theme template.
*
*/

function garland_preprocess_ddblock_cycle_pager_content(&$vars) {
if (($vars['output_type'] == 'view_fields') && ($vars['pager_settings']['pager'] == 'custom-pager')){
$content = array();
// Add pager_items for the template
// If you use the devel module uncomment the following lines to see the theme variables
// dsm($vars['pager_settings']['view_name']);
// dsm($vars['content'][0]);
// If you don't use the devel module uncomment the following lines to see the theme variables
// drupal_set_message('

' . var_export($vars['pager_settings'], true) . '

');
// drupal_set_message('

' . var_export($vars['content'][0], true) . '

');
if ($vars['pager_settings']['view_name'] == 'ddblock_embedded_video') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
// add pager_item_image variable
if (isset($result->node_data_field_pager_item_text_field_image_fid)) {
$fid = $result->node_data_field_pager_item_text_field_image_fid;
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)
if (module_exists('imagecache') &&
is_array(imagecache_presets()) &&
$vars['imgcache_pager_item'] <> ''){
$pager_items[$key1]['image'] =
theme('imagecache',
$vars['pager_settings']['imgcache_pager_item'],
$filepath,
check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value));
}
else {
$pager_items[$key1]['image'] =
'Only local images are allowed. '" alt="' . check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value) .
'"/>';
}
}
// add pager_item _text variable
if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) {
$pager_items[$key1]['text'] = check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value);
}
}
}
}if ($vars['pager_settings']['view_name'] == 'ddblock_embedded_video') {
foreach ($vars['content'] as $key1 => $result) {
// add pager_item_image variable
// add youtube video thumbnail
if (isset($result->node_data_field_custom_pager_text_field_embedded_video_url_data)) {
$data=unserialize($result->node_data_field_custom_pager_text_field_embedded_video_url_data);
if (isset($data['thumbnail']['url'])) {
$pager_items[$key1]['image'] = 'Only local images are allowed. '" alt="' . $result->node_data_field_custom_pager_text_field_custom_pager_text_value .
'"/>';
}
}
// add pager_item _text variable
if (isset($result->node_data_field_custom_pager_text_field_custom_pager_text_value)) {
$pager_items[$key1]['text'] = $result->node_data_field_custom_pager_text_field_custom_pager_text_value;
}
}
}

$vars['pager_items'] = $pager_items;
}
}

/**
* Add a "Comments" heading above comments except on forum pages.
*/
function garland_preprocess_comment_wrapper(&$vars) {
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['content'] = '

'. t('Comments') .'

'. $vars['content'];
}
}

/**
* Returns the rendered local tasks. The default implementation renders
* them as tabs. Overridden to split the secondary tasks.
*
* @ingroup themeable
*/
function phptemplate_menu_local_tasks() {
return menu_primary_local_tasks();
}

function phptemplate_comment_submitted($comment) {
return t('!datetime — !username',
array(
'!username' => theme('username', $comment),
'!datetime' => format_date($comment->timestamp)
));
}

function phptemplate_node_submitted($node) {
return t('!datetime — !username',
array(
'!username' => theme('username', $node),
'!datetime' => format_date($node->created),
));
}

/**
* Generates IE CSS links for LTR and RTL languages.
*/
function phptemplate_get_ie_styles() {
global $language;

$iecss = '
';
if ($language->direction == LANGUAGE_RTL) {
$iecss .= '

@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";

';
}

return $iecss;
}

ppblaauw’s picture

Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Active

The code in the ddblock preprocess function is not right.

Edit: See #5 why the code does not look right, maybe it is

There are several errors (if statement don't close right, string values don't close right) and duplicate code in the preprocess functions. I don't see version information for the ddblock preprocess functions, so I don't know where they come from.

Did you make the changes here yourself or did you copy the changed preprocess from somewhere.

I advise you to use the preprocess function from the latest export_files downloads for RC6 of the module at http://ddblock.myalbums.biz and change [theme-name] and view names again

Hope this helps you further, please let me know.

ppblaauw’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Change priority to: normal and status to: postponed (maintainer needs more info)

OnthegOinOz’s picture

Ok... I thought i followed the instructions pretty clearly.

1. I opened the garland template.php file
2. I inserted the contents of the Version 1.6 ddblock template file at the bottom of the garland template.php file
3. I then inserted the contents of the preprocess_function_ddblock_embedded_video (in two sections) into the ammended garland template.php file. i.e."Copy the following code and paste it in your template.php file. Add the following if statement before $vars['slider_items'] = $slider_items; to the [theme_name]_preprocess_ddblock_cycle_block_content"

which by my understanding means to place the first section of code from 'preprocess_function_ddblock_embedded_video' on the line before $vars['slider_items'] = $slider_items which was added to the garland tamplate.php file from the Version 1.6 ddblock template file. Then the second bit of code from 'preprocess_function_ddblock_embedded_video' on the line before $vars['pager_items'] = $pager_items which was added to the garland tamplate.php file from the Version 1.6 ddblock template file.

This is what I did so perhaps I have understood the instructions?

ppblaauw’s picture

The steps you describe are right.

The preprocess functions to add to your template.php file should look as follows.
See attachment

Hope this helps you further.

P.S. I see now that in comment #1 where you posted the code of the preprocess function, that some parts are not shown because of html tags like the <img> tag. (So, maybe your code was already correct)

When posting code which contains html tags put your code between

<code>
...
<code>

or

<?php
...
?>

Or add it as an attachment

See also the Input format block below for a description of the input formats

OnthegOinOz’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

Ok, thanks for that... I have now copied into and replaced the garland template.php file with what you have attached above. I now get this:

Fatal error: Call to undefined function phptemplate_get_ie_styles() in /.../.../.../.../themes/garland/page.tpl.php on line 12

OnthegOinOz’s picture

silly me... i did not add it to the existing template file... and then i did not take out the and then i had not added the at the end...... I think I have it sorted now!

I am so not a coder... perhaps i'll slowly pick up this on the way.

thanks heaps Phillip

OnthegOinOz’s picture

wait a minute... it stills comes back blank when I post something???

Not sure what else is happening but when I try to run the update.php i get a page with "" and this alone

and it still has the error warning: Cannot modify header information - headers already sent by (output started at /.../.../.../.../themes/garland/template.php:1) in /.../.../.../.../includes/common.inc on line 148.

ppblaauw’s picture

This does not sound related to the ddblock module.

One thing I noticed in your description:

You say your template.php is ended with ?>

---

The template.php file starts with <?php but is NOT ended with ?>

Hope this helps you further

OnthegOinOz’s picture

Really not sure whats happening now... I just tried a fresh install with onl the modules enabled for DDBlock. After inserting details as you have listed (except editing remaining 'news_items"which sneaked in :) I end up with what is below.

I then go to import the content type file and it goes to a blank page at .../admin/content/types/import... same as before. Would you mind checking to see where I stuffed up?:

<?php
// $Id: template.php,v 1.16.2.2 2009/08/10 11:32:54 goba Exp $

/**
* Sets the body-tag class attribute.
*
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
*/
function phptemplate_body_class($left, $right) {
if ($left != '' && $right != '') {
$class = 'sidebars';
}
else {
if ($left != '') {
$class = 'sidebar-left';
}
if ($right != '') {
$class = 'sidebar-right';
}
}

if (isset($class)) {
print ' class="'. $class .'"';
}
}

/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
* An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '

';
}
}

/**
* Override or insert PHPTemplate variables into the templates.
*/
function phptemplate_preprocess_page(&$vars) {
$vars['tabs2'] = menu_secondary_local_tasks();

// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
}

/**
* Add a "Comments" heading above comments except on forum pages.
*/
function garland_preprocess_comment_wrapper(&$vars) {
if ($vars['content'] && $vars['node']->type != 'forum') {
$vars['content'] = '

'. t('Comments') .'

'. $vars['content'];
}
}

/**
* Returns the rendered local tasks. The default implementation renders
* them as tabs. Overridden to split the secondary tasks.
*
* @ingroup themeable
*/
function phptemplate_menu_local_tasks() {
return menu_primary_local_tasks();
}

function phptemplate_comment_submitted($comment) {
return t('!datetime — !username',
array(
'!username' => theme('username', $comment),
'!datetime' => format_date($comment->timestamp)
));
}

function phptemplate_node_submitted($node) {
return t('!datetime — !username',
array(
'!username' => theme('username', $node),
'!datetime' => format_date($node->created),
));
}

/**
* Generates IE CSS links for LTR and RTL languages.
*/
function phptemplate_get_ie_styles() {
global $language;

$iecss = '
';
if ($language->direction == LANGUAGE_RTL) {
$iecss .= '

@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";

';
}

return $iecss;
}

/*!
* Dynamic display block preprocess functions
* Copyright (c) 2008 - 2009 P. Blaauw All rights reserved.
* Version 1.6 (01-OCT-2009)
* Licenced under GPL license
* http://www.gnu.org/licenses/gpl.html
*/

/**
* Override or insert variables into the ddblock_cycle_block_content templates.
* Used to convert variables from view_fields to slider_items template variables
*
* @param $vars
* An array of variables to pass to the theme template.
*
*/
function garland_preprocess_ddblock_cycle_block_content(&$vars) {
if ($vars['output_type'] == 'view_fields') {
$content = array();
// Add slider_items for the template
// If you use the devel module uncomment the following line to see the theme variables
// dsm($vars['settings']['view_name']);
// dsm($vars['content'][0]);
// If you don't use the devel module uncomment the following line to see the theme variables
// drupal_set_message('

' . var_export($vars['settings']['view_name'], true) . '

');
// drupal_set_message('

' . var_export($vars['content'][0], true) . '

');
if ($vars['settings']['view_name'] == 'news_items') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
// add slide_image variable
if (isset($result->node_data_field_pager_item_text_field_image_fid)) {
// get image id
$fid = $result->node_data_field_pager_item_text_field_image_fid;
// get path to image
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)
if (module_exists('imagecache') && is_array(imagecache_presets()) && $vars['imgcache_slide'] <> ''){
$slider_items[$key1]['slide_image'] =
theme('imagecache',
$vars['imgcache_slide'],
$filepath,
check_plain($result->node_title));
}
else {
$slider_items[$key1]['slide_image'] =
'Only local images are allowed. '" alt="' . check_plain($result->node_title) .
'"/>';
}
}
// add slide_text variable
if (isset($result->node_data_field_pager_item_text_field_slide_text_value)) {
$slider_items[$key1]['slide_text'] = check_markup($result->node_data_field_pager_item_text_field_slide_text_value);
}
// add slide_title variable
if (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = check_plain($result->node_title);
}
// add slide_read_more variable and slide_node variable
if (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', 'node/' . $result->nid);
$slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid;
}
}
}
}
if ($vars['settings']['view_name'] == 'ddblock_embedded_video') {
//drupal_set_message('

' . var_export($vars['settings']['view_name'], true) . '

');
//drupal_set_message('

' . var_export($vars['content'][0], true) . '

');

foreach ($vars['content'] as $key1 => $result) {
// add youtube video thumbnail
if (isset($result->node_data_field_custom_pager_text_field_embedded_video_url_data)) {
$data=unserialize($result->node_data_field_custom_pager_text_field_embedded_video_url_data);
//print '

';
          //print_r($data);
          //print '

';
if (isset($data['thumbnail']['url'])) {
$slider_items[$key1]['slide_image'] = 'Only local images are allowed. '" alt="' . $result->node_data_field_custom_pager_text_field_custom_pager_text_value .
'"/>';
}
}
// add slide_text variable
if (isset($result->node_data_field_custom_pager_text_field_slider_text_value)) {
$slider_items[$key1]['slide_text'] = $result->node_data_field_custom_pager_text_field_slider_text_value;
}
// add slide_title variable
if (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = $result->node_title;
}
// add slide_read_more variable and slide_node variable
if (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Play now...', 'node/' . $result->nid);
$slider_items[$key1]['slide_node'] = 'node/' . $result->nid;
}
}
}
$vars['slider_items'] = $slider_items;
}
}
/**
* Override or insert variables into the ddblock_cycle_pager_content templates.
* Used to convert variables from view_fields to pager_items template variables
* Only used for custom pager items
*
* @param $vars
* An array of variables to pass to the theme template.
*
*/
function garland_preprocess_ddblock_cycle_pager_content(&$vars) {
if (($vars['output_type'] == 'view_fields') && ($vars['pager_settings']['pager'] == 'custom-pager')){
$content = array();
// Add pager_items for the template
// If you use the devel module uncomment the following lines to see the theme variables
// dsm($vars['pager_settings']['view_name']);
// dsm($vars['content'][0]);
// If you don't use the devel module uncomment the following lines to see the theme variables
// drupal_set_message('

' . var_export($vars['pager_settings'], true) . '

');
// drupal_set_message('

' . var_export($vars['content'][0], true) . '

');
if ($vars['pager_settings']['view_name'] == 'ddblock_embedded_video') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
// add pager_item_image variable
if (isset($result->node_data_field_pager_item_text_field_image_fid)) {
$fid = $result->node_data_field_pager_item_text_field_image_fid;
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)
if (module_exists('imagecache') &&
is_array(imagecache_presets()) &&
$vars['imgcache_pager_item'] <> ''){
$pager_items[$key1]['image'] =
theme('imagecache',
$vars['pager_settings']['imgcache_pager_item'],
$filepath,
check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value));
}
else {
$pager_items[$key1]['image'] =
'Only local images are allowed. '" alt="' . check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value) .
'"/>';
}
}
// add pager_item _text variable
if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) {
$pager_items[$key1]['text'] = check_plain($result->node_data_field_pager_item_text_field_pager_item_text_value);
}
}
}
}
if ($vars['pager_settings']['view_name'] == 'ddblock_embedded_video') {
foreach ($vars['content'] as $key1 => $result) {
// add pager_item_image variable
// add youtube video thumbnail
if (isset($result->node_data_field_custom_pager_text_field_embedded_video_url_data)) {
$data=unserialize($result->node_data_field_custom_pager_text_field_embedded_video_url_data);
if (isset($data['thumbnail']['url'])) {
$pager_items[$key1]['image'] = 'Only local images are allowed. '" alt="' . $result->node_data_field_custom_pager_text_field_custom_pager_text_value .
'"/>';
}
}
// add pager_item _text variable
if (isset($result->node_data_field_custom_pager_text_field_custom_pager_text_value)) {
$pager_items[$key1]['text'] = $result->node_data_field_custom_pager_text_field_custom_pager_text_value;
}
}
}
$vars['pager_items'] = $pager_items;
}
}

OnthegOinOz’s picture

The same thing has happened when after I imported the views settings and then clicked save... then blank page at .../admin/build/views/edit/ddblock_embedded_video

heine’s picture

and it still has the error warning: Cannot modify header information - headers already sent by (output started at /.../.../.../.../themes/garland/template.php:1) in /.../.../.../.../includes/common.inc on line 148.

Emphasis added.

There's whitespace before the opening <?php tag in template.php. If you don't see any, it is likely that your texteditor saved the file as "UTF-8 with B(yte) O(rder) M(ark)". Make sure to save the file as UTF-8 without a BOM.

OnthegOinOz’s picture

worked a treat.... thanks Heine!!

ppblaauw’s picture

Thanks Heine, again learned something which can be difficult to pinpoint.

Set status to fixed

ppblaauw’s picture

Status: Postponed (maintainer needs more info) » Fixed

And now for real.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.