When using iframe canvas the theme needs to execute the fb_canvas_process($output); function

CommentFileSizeAuthor
fb_canvas_add_iframe_to_theme.patch461 bytesjcmarco

Comments

jcmarco’s picture

Status: Active » Needs review
Dave Cohen’s picture

Status: Needs review » Fixed

Thanks.

Checked it in, will be in beta 3.

mikerasmussen’s picture

This is now broken with beta3. Not sure what is happening...

mikerasmussen’s picture

Status: Fixed » Needs review

I think this is related to the "add_target" variable. I tried to make the following change:

  if (fb_canvas_is_fbml()) {
    // Drupal provides no post-process for themes.
    $output = fb_canvas_process($output, array('force_absolute_canvas' => TRUE));
  }
  
  if (fb_canvas_is_iframe()) {
    // Drupal provides no post-process for themes.
    $output = fb_canvas_process($output, array('add_target' => TRUE));
  } 

to fb_canvas.module on line 764.

When I comment out the if statement on line 656:

//if (isset($options['add_target']) && $option['add_target']) {

(and the subsequent else) it works. However, passing the argument as you do with array('add_target' => TRUE) does not seem to pass this condition.

Dave Cohen’s picture

Sorry entirely my fault. Let me know if this patch fixes...

Index: fb_canvas.module                                                         
===================================================================
--- fb_canvas.module    (revision 2209)                                         
+++ fb_canvas.module    (working copy)                                          
@@ -651,7 +651,7 @@
       // In iframe                                                             
       // Add target=_top so that entire pages do not appear within an iframe.  
       // TODO: make these pattern replacements more sophisticated, detect whet\
her target is already set.                                                      
-      if (isset($options['add_target']) && $option['add_target']) {            
+      if (isset($options['add_target']) && $options['add_target']) {           
         // Add target=_top to all links                                        
         $patterns[] = "|<a |";                                                 
         $replacements[] = "<a target=\"_top\" ";                               
@@ -757,10 +757,12 @@
                                                                                
   $output = theme('fb_canvas_page_orig', $content, $show_blocks, $show_message\
s);                                                                             
                                                                                
-  if (fb_canvas_is_fbml() || fb_canvas_is_iframe()) {                          
-    // Drupal provides no post-process for themes.                             
+  if (fb_canvas_is_fbml()) {                                                   
     $output = fb_canvas_process($output, array('force_absolute_canvas' => TRUE\
));                                                                             
   }                                                                            
+  else if (fb_canvas_is_iframe()) {                                            
+    $output = fb_canvas_process($output, array('add_target' => TRUE));         
+  }                                                                            
                                                                                
   return $output;                                                              
 }                                                                              

psi-borg’s picture

Dave, your patch worked for my dff iframe app - thank you.