When I use both the "Basic Popup Window" or "iframe" the theme's layout is rendered, i.e. the cropping settings are rendered essentially the same way as a normale page... is this by design?

I would've expecte to only get the settings in the popup/iframe, without sidebars etc.

Comments

bforchhammer’s picture

Status: Active » Closed (works as designed)

Hm, I think I've figured out why... I'm using the Context module to manage the placement of all blocks in my theme. Because of that I disabled all of them on the default block page, including "main content"... As a result imagecrop_page() couldn't detect the "main region" properly, and as a fallback the whole layout was used (or so it seems).

So in case anyone else ever gets this problem: go to admin/structure/blocks and make sure the "Main Content" block is assigned to the main region on your theme. ;-)

gagarine’s picture

Status: Closed (works as designed) » Active

Sometimes you don't want the main region in block. Perhaps we can make this module play nice with context.

gagarine’s picture

Title: Popup renders theme layout (sidebars etc.) » Break if context magage the main block.

Update title.

The module should a least provide a error message instead of displaying all region if it can't find the main block

bforchhammer’s picture

I actually ended up using the following piece of code in a custom module:

/**
 * Implements hook_theme_registry_alter().
 */
function MYMODULE_theme_registry_alter(&$theme_registry) {
  $theme_registry['page-imagecrop']['function'] = 'MYMODULE_imagecrop_page';
}

/**
 * Circumvent imagecrop's "main region detection" code, which fails in our case
 * because it depends on the position of the "Main Content" block.
 *
 * @see imagecrop_page() in imagecrop.theme.inc
 */
function MYMODULE_imagecrop_page($variables) {
  $output = '';
  if (isset($variables['messages'])) {
    $output .= $variables['messages'];
  }
  $output .= imagecrop_render_main_content($variables['page']['content']);
  return $output;
}
jcfiala’s picture

For that matter, here at Examiner.com we're using mongo_block instead of the block module, and as such just _querying_ for the block table crashes this module, as it doesn't exist. It'd be nice if this module checked to see if the block module was enabled.

phpconnect’s picture

I have use "$output .= render($variables['page']['content']);" in drupal 7 thanks for help

nils.destoop’s picture

Status: Active » Fixed

Imagecrop now checks if block module is enabled, otherwise it will use the content region.
If the block is not found, a message is shown. If it is another case, #4 is recommended.

Status: Fixed » Closed (fixed)

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

paskainos’s picture

Imagecrop now checks if block module is enabled...

This doesn't seem to solve the problem when using Context with the Boxes or Dashboard modules, for instance, which require Block enabled. Further, anyone using Context should be familiar / aware of how & where to invoke the 'Main page content' block. For instance, here's a use case I thought would work, but didn't:

Using Context, Boxes, Dashboard, and Block (as required by Boxes & Dashboard) with all admin/structure/block blocks including 'Main page content' block disabled, I created a 'global' context for sitewide front facing (i.e. non-admin) blocks. I included the path ~imagecrop/* so as not to include the various and sundry sitewide blocks in the imagecrop modal window. Then I created an 'imagecrop' context, added Conditions » Path » imagecrop/*, and Reactions » Blocks » 'Main page content' block in Main Content region.

Using this recipe, no matter what Popup window type I use, I still receive the 'main content block was not found' error message. For what it's worth, I'm using the settiing: Theme beïng used » Admin theme (Rubik).

kclarkson’s picture

@paskainos,

I just figured this out. I have a sitewide context for my sidebar and my main block content.

Add the URL context then add ~imagecrop/overview/*

then make sure to select REQUIRED ALL CONDITIONS check box on the context.

So in the end you should have
-required all conditions checked
-path (~imagecrop/overview/*)
-sitewide

jhodgdon’s picture

None of these solutions will work except the suggestion in #4 for the case where you have the main content region disabled for other reasons, and you are using the Context module instead to handle when the content region is or is not enabled.

Thanks bforchhammer for providing that!!!