Can someone advise me on how to fix a bug between my site and the pageFlip module. I’ve installed the pageFlip modules and imported the content types forpageflip 6.x-1.0-beta1. Adding pages and chapters is okay. But when I add submit Books, I get the following error message:

warning: Invalid argument supplied for foreach() in /cck/content.module on line 1284.

I thought it might be a missing CCK reference. I imported the content types in this order page, chapter, book. I also installed the Better Formats module (afterwards) because I saw that it was referenced in the page content type code. Please let me know if you have any ideas. For now, the book is not showing at all.

Thanks,

-Ozie

Comments

galis007’s picture

Flash viewer requires MegaZine3 -- unpack it into (e.g.) sites/all/libraries/mz3
So ensure u download megazine3 and unpack the contents to the location above

alan d.’s picture

Status: Active » Postponed (maintainer needs more info)

This may have something to so with the default value(s) of one or more fields.

The error line is in the function _content_field_invoke_default().

<?php
  foreach ($type['fields'] as $field) {
    ....
  }
?>

What fields exist for the book content items? Try editing each and saving them (no changes should be required) and trying again. The exported defaults may be causing issues here.

alan d.’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Needs review

Big WTF here. There is site specific code to show the non-flash content. The module tries to load content item with id 64 and irrespective of the results, the node or NULL is passed through into page_view(). With no fault of the core system, core starts throwing errors. GIGO

<?php
// @todo: make this nid settable through admin page
// this is the node whose content should be shown under the Flash player in
// case the Flash fails to load for some reason.
define('PAGEFLIP_MZ3_VIEWER_FLASH_NODE', 64);
.....
  $page = node_load(PAGEFLIP_MZ3_VIEWER_FLASH_NODE);
  return node_view($page) . $html_link;
?>

So dropping the define(), adding a admin configurable message & using this instead prevents this error.

The admin option code.

<?php
/**
 * Build our admin settings form.
 */
function pageflip_mz3_viewer_settings_form($form_state) {
  $form = array();
  .......
  $form['no_flash'] = array(
    '#type' => 'textarea',
    '#title' => ('No flash content'),
    '#description' => t('The default no flash message in case flash does not load. If you only enter a node nid, this node will be displayed.'),
    '#default_value' => variable_get('pageflip_mz3_viewer_no_flash', t('<p>Please install flash to view this page.</p>')),
  );
  .......
  return $form;
}

/**
 * Validate our admin settings form.
 */
function pageflip_mz3_viewer_settings_form_validate($form, &$form_state) {
  ........
  if (!empty($form_state['values']['no_flash']) && is_numeric($form_state['values']['no_flash']) && !node_load($form_state['values']['no_flash'])) {
    form_set_error('no_flash', t("Can't load node @nid", array('@nid' => $form_state['values']['no_flash'])));
    return FALSE;
  }
  return TRUE;
}

/**
 * Process validated admin settings form.
 */
function pageflip_mz3_viewer_settings_form_submit($form, &$form_state) {
  $variables = array(
    'megazine3_path',
    'back_cover_nid',
    'allow_fullscreen',
    'bg_color',
    'book_attributes',
    'front_cover_attributes',
    'page_attributes',
    'back_cover_attributes',
    'no_flash',
  );
  .....
}
?>

The view code.

<?php

function pageflip_mz3_viewer_view($node) {
  ........
  $additional_content = trim(variable_get('pageflip_mz3_viewer_no_flash', t('<p>Please install flash to view this page.</p>')));
  if (is_numeric($additional_content)) {
    if ($node = node_load($additional_content)) {
      $additional_content = node_view($node, FALSE, FALSE, FALSE);
    }
    else {
      $additional_content = '';
    }
  }

  $html_link = '<p>'. t('View this story in the !player.', array('!player' => l(t('HTML/JavaScript player'), 'node/'. $node->nid .'/pageflip/html-viewer'))) .'</p>';
  return $additional_content . $html_link;
}

?>
jesusns’s picture

This work fine:

"patch:

Replace line 1284:
else {
with
else if (count($type['fields'])>0) {"

https://drupal.org/node/716878

adamdicarlo’s picture

Yep, that is a big WTF that I missed when reviewing the module to submit it to contrib.

I'm not so sure about needing to patch CCK. I think once I include the pageflip_content_types feature (yeah, you'll have to install Features if you haven't already) that will help people get up and started much more quickly.

Alan D's work looks like a decent solution (simple text field that optionally can be a nid). I'll be reviewing it soon with the big big patch over in #915878: Combined issue queue patch.

pdemil’s picture

Thanks Alan D! Now I get
"please install flash to view this page.
View this story in the HTML/JavaScript player."

But I can't click on HTML/JavaScript player. Actually, I can't click anywhere in the site, it seems to be frozen.

edwinnur’s picture

I have try that, but I can't see mz3 viewer.
I just see link HTML/Javascript player. How do I fixed it?

edwinnur’s picture

Now I can see mz3 viewer but the navigationbar not show and the page resolution can't be zoom

david3000’s picture

hello guys :-) any news about this issue? still the same error msg on 6.x-1.0-beta4 module. I don't wanna hacks any module...hope there is a better solution. greetings!

david3000’s picture

Hello guys, any news about this? The module runs great, but this warning show up every time when I open books. The book opened work fine. It's just the waring message the problem. Any help? thanks

Anonymous’s picture

Same problem here - I'm using 6.x-1.0-beta4. What's the status on this?

Subscribing, please fix soon! Thanks...

adamdicarlo’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Assigned: Unassigned » adamdicarlo

This is being caused by content_preprocess_node() being passed what looks like the result of node_build_content(NULL) in $vars['node']. Very weird. I'm trying to track it down, now, but I'm wondering if time would be better spent exporting these content types and fields to a features module instead.

adamdicarlo’s picture

Just committed a fix. I somehow lost track that I had never fixed the bug described by Alan D. in #3. D'oh.

http://drupalcode.org/project/pageflip.git/commit/9ba4165bd0ef1b2e1591ed...

Will follow up to add a new admin interface to specify the default Flash fallback content.

adamdicarlo’s picture

Status: Needs review » Fixed

Added the admin interface, again by adapting Alan D.'s code a bit:
http://drupalcode.org/project/pageflip.git/commit/f0f3a5a1b87d444f7423a3...

Status: Fixed » Closed (fixed)

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