I wanted to set a class to the body of modalframe-page.tpl.php. I suggest this as a feature, but when wanting to do that, i noticed that my modalframe-page.tpl.php does not overwrite the one shipped with modalFrame.

Comments

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)

You should be able to copy modalframe-page.tpl.php to your theme directory and Drupal should get that one. You may need to rebuild the theme registry. Then you can alter the contents of that template as you wish.

If that does not happen, there may be something odd in your installation.

You can also override the stylesheets provided by Modal Frame API using a copy in your theme that's referenced in your theme's .info file.

Other that that, I'm unable to reproduce this issue. It just works here.

Michsk’s picture

aha ok, so i figured out that this does not work when the file is in a folder.

WORKS: /sites/all/themes/theme/modalframe-page.tpl.php

DOES NOT WORK: /sites/all/themes/theme/templates/modalframe/modalframe-page.tpl.php

So this does count as a bug right?

Michsk’s picture

Status: Postponed (maintainer needs more info) » Fixed

wtf now it also works in subdirs... i have no idea what happend, maybe caching of the iframe in my browser? No idea, thanks anyway.

Michsk’s picture

Status: Fixed » Needs review

No. this issue is still there. Only works when you place the template in your main template folder, placing it in a subdir doesn't work. I just doesnt overwrite then.

markus_petrux’s picture

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

I think Drupal is able to scan subdirectories of the theme. Well, we have a theme where all template overrides are located in MYTHEME/templates and I do not recall we did anything special to get that working.

So I cannot reproduce your issue either yet.

Michsk’s picture

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

yes drupal is able to do that, but this is the only case where it does not work for me. anyway i can not provide more info, so might as well close this.

markus_petrux’s picture

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

hmmm... you may also need to override the page.tpl.php. ie. copy this one also to the same place you want the one that uses modal frame. Clear the Drupal caches after changing this kind of things.

PS: "needs review" is tobe used when there's a patch for review. Meanwhile, since I cannot reproduce, let's leave it as "needs more info".

Michsk’s picture

good point, i'll check this tomorrow.

mattiasj’s picture

I would personally be very fond of the idea that the body had a unique class in the modalframe-page.tpl so that it could be styled different. Then we wouldn't even need to use the template.

markus_petrux’s picture

@mattiasj: The modalframe template provides a wrapper for the whole content with a unique class. Doing this also for the body, if that helps, then that's a good idea, but please open a separate feature request (we're trying to deal with a "bug report" here), and it would also be nice if that comes with a patch. I would be glad to review and commit that in short time. Thanks

jghyde’s picture

Just a tip on how to force the modalframe-page.tpl.php. In phptemplate_preprocess_page ():


<?php
/* Assumptions:

1. Place the trailing alias 'gomodal' behind the URL you want to open in
a modal frame. Do this generally as as a path alias, using the path module

2. Replace 'phptemplate' with your own theme's name

 */

$vars['path_alias'] = drupal_get_path_alias(phptemplate_request_path());

if (module_exists('modalframe')) {
  if (strpos($vars['path_alias'], 'gomodal')) {
    modalframe_child_js();
    $vars['template_file'] = 'modalframe-page';
  }
}
?>
<?php
// Definitive way to figure out request URI, coming soon to D7

/**
 *  Returns the requested URL path of the page being viewed.
 *  http://api.drupal.org/api/function/request_path/7
 * Examples:
 *
 *   * http://example.com/node/306 returns "node/306".
 *   * http://example.com/drupalfolder/node/306 returns "node/306" while base_path() returns "/drupalfolder/".
 *   * http://example.com/path/alias (which is a path alias for node/306) returns "path/alias" as opposed to the internal path.
 *
 * See also
 *
 * current_path()
 * Return value:
 *
 * The requested Drupal URL path.
 */
function phptemplate_request_path() {
  static $path;

  if (isset($path)) {
    return $path;
  }

  if (isset($_GET['q'])) {
    // This is a request with a ?q=foo/bar query string. $_GET['q'] is
    // overwritten in drupal_path_initialize(), but request_path() is called
    // very early in the bootstrap process, so the original value is saved in
    // $path and returned in later calls.
    $path = $_GET['q'];
  }
  elseif (isset($_SERVER['REQUEST_URI'])) {
    // This is a request using a clean URL. Extract the path from REQUEST_URI.
    $request_path = strtok($_SERVER['REQUEST_URI'], '?');
    $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
    // Unescape and strip $base_path prefix, leaving q without a leading slash.
    $path = substr(urldecode($request_path), $base_path_len + 1);
  }
  else {
    // This is the front page.
    $path = '';
  }

  // Under certain conditions Apache's RewriteRule directive prepends the value
  // assigned to $_GET['q'] with a slash. Moreover we can always have a trailing
  // slash in place, hence we need to normalize $_GET['q'].
  $path = trim($path, '/');

  return $path;
}
?>

?>

tsi’s picture

I've found that the only condition is that modalframe-page.tpl.php and page.tpl.php must be in the same directory, works for me in both theme root or theme subdirectory.

tpainton’s picture

I have to say, that I have the same problem I copied modalframe-page.tpl.php to my theme folder. The same directory also holds page.tpl.php. I cleared server cache, I rebuilt the theme registry but I do not get the custom modalframe-page.tpl.php. IN fact, my modalframe-page.tpl.php is blank yet I still get the page content in a modal frame. I have changed browsers as well, and loaded page using ctrl-f5.. I'm at a loss. I use custom templates all the time.

tpainton’s picture

Version: 6.x-1.x-dev » 6.x-1.7

Okay, now it's really bizarre. The custom modalframe-page.tpl.php is used from automodal links but not from links that only use automodal API alone. Why on earth would this be happening. Investigating further.

tpainton’s picture

I am wits end. I have uninstalled automodal fearing that it might be part of the trouble. I am calling my modal windows, which open just fine using a very simple js file..


/**
 * Facilitates modalframe windows opening from the god_geo_view page.
 */
(function ($) {

Drupal.behaviors.modalFrameView = function() {
  $('.modalframe-child:not(.modalframe-processed)').addClass('modalframe-processed').each(function() {

	var $link = $(this), url = $link.attr('href');
        
	$link.click(function() {
        Drupal.modalFrame.open({url: url, width: 800, height: 600, autoFit: 1});
        return false;
      });
  });
};

})(jQuery);

I have copied modalframe-page.tpl.php to my theme's template directory where there is also the original page.tpl.php file. I have changed themes to reset the theme registry. I have flushed cache from the Dev menu, I have flushed the browser cache and I am still getting sidebars, headers, and footers in modal child windows when the url is l('node', 'node/343', array('attributes' => array('class' => 'modalframe-child')) called.

I can't imagine that this isn't some sort of bug... Unless someone can point me to where I am making an error?

/edit.. Not theme related. Persists in all themes.

/edit I THINK I JUST REALIZED MY FOLLY. I had my modalframe_child_js() commented out.. testing.

tpainton’s picture

Yes, I solved it. I forgot that I had commented out modalframe_child_js() when I was messing around with automodal. Well. That was a great 2 hours spent pouring over the modalframe code looking for a bug. I should have known better. I would venture that this is the original problem that started the whole post. For me, this was a custom node, so I just added modalframe_child_js() to my hook_view(), but if one is viewing a stock drupal node then the hook_view() needs to be altered to include the modalfram_child_js(). If this isn't done, then one would get this issue. Personally, I never dreamed the modalframe_child_js() was commented out because I assumed without it, the modal would not open.. It does, just not in a pretty way.

dsnopek’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (works as designed)

As for the original issue: this is well known Drupal 6 bug - you have to have the main template (ie. page.tpl.php) in your theme before Drupal will find any of the suggestions for it (ie. modalframe-page.tpl.php). It's fixed in Drupal 7. ;-)

It looks like the @tpainton was able to solve his problem himself. Closing!