#1697738: Page Tabs URL rewriting not working? does a great job of explaining how to override the tab settings on a link by link basis, but I'd like to go a slightly different route.

What I really want is the ability to turn this on and off for a single tab. So two of my tabs would behave like the standard and send all links externally (using the rewrite), and one would leave them as canvas links.

I attempted to add this to the page:

  global $_fb, $_fb_app;
  if(!empty($_fb_app)) {
    $_fb_app->canvas = TRUE;
  }

Which I can confirm applied by looking at the debug information. But I have a sneaking suspicion this is too late in the process to make a difference.

Comments

Dave Cohen’s picture

Category: feature » support

Right now, the treatment of links on a page tab is site wide. A reasonable feature request would be to make it on a per-app basis instead. (modules/fb has two sets of settings, site-wide and app-specific).

You're asking for a different setting *per tab*. A change like that doesn't belong in the module. Hopefully modules/fb is flexible enough for you to accomplish this with custom code.

Basically you have to configure fb_tab.module to not process the links in any way. Then introduce your own logic to either process or not depending on your per-tab settings.

When you look through fb_tab.module to see how this is accomplished, you may not like what you see. It jumps through some hoops to save the page output to a buffer, then process on exit.

Your work *might* be simpler. You'll have to try this and see if it works....

Write a custom module, and weight it so its hooks are called before fb_tab.module. Implement hook_fb(). When $op == FB_OP_INITIALIZE, have some logic along the lines of...

if (this_tab_needs_link_processing()) {
  $GLOBALS['conf'][FB_TAB_VAR_PROCESS_IFRAME] = TRUE;
}

That code is basically trying to change the variable on a per-request basis. It's not the most robust practice, but likely your easiest way to do something like this. If it works, please share the relevant snippets here.

Dave Cohen’s picture

Oh, hey Mark. I just realized who I was replying to.

The other strategy you could employ is tell fb_tab.module not to process links. Then, carefully construct the link on your tab to behave the way you want. This option is possible if your tab content is completely under your control. By that I mean, if you display for instance a drupal menu, all the links get default treatment. But, if you control the page completely, you can generate a links...

$default_link = l('test1', 'path/to/whatever');

$non_altered_link = l('test2', 'path/to/whatever', array('fb_url_alter' => FALSE));

Those links should behave differently, although I haven't done this much with tabs. It might take some experimenting and maybe patches to get it to work exactly as you would like.

mrf’s picture

Hey dave, thanks for all the pointers.

Ended up running out of time and turning this on its head. I disabled processing and made sure all my external links were opening externally rather than the other way around.

fb_url_alter on the links didn't work as expected, but I didn't have any luck pinpointing why.