Hello,

I'm trying to implement Magic_Tabs on my custom profile pages. The code I have in user_profile.tpl.php looks like:

function magic_tabs_profile_callback() {
  $tabs[] = array(
    'title' => t('About'),
	'content' => dload_profile_about_tab(),
  );
  $tabs[] = array(
    'title' => t('Friends'),
	'content' => dload_profile_friends_tab(),
  );
  $tabs[] = array(
    'title' => t('Activity'),
	'content' => dload_profile_activity_tab(),
  );
  $tabs[] = array(
    'title' => t('Tags'),
	'content' => dload_profile_tags_tab(),
  );
  return $tabs;
} 

dload_profile* are custom functions which return HTML code. My problem is that no matter which tab I click on, after the load animation the entire magic tab section (tabs and all!) disappear. I am able to go to the magic tab URLs directly, and everything looks ok. For example:

/users/username?magic_tabs_profile_callback_tab=0
/users/username?magic_tabs_profile_callback_tab=1
/users/username?magic_tabs_profile_callback_tab=2
/users/username?magic_tabs_profile_callback_tab=3

All load the content as expected, and things appear fine. As soon as I click on a tab, magic_tabs vanishes.

I've spent 5 hours working on this problem alone. The many CSS changes I thought could help didn't have an impact. Any suggestions on what else to try or debug this problem?

magic_tabs_example_callback works OK on these same profile pages, but my custom content does not.

Thanks for any assistance here,
.

Comments

d0t101101’s picture

FINALLY made some progress on this :)

When I moved my tab related code (callback and supporting functions) to a module, it works as expected. Are there any limitations with using magic_tabs directly in user_profile.tpl.php? Or maybe some requirements for how custom functions are declared inside of a tpl!

Regards,
.

yhager’s picture

Component: Code » Documentation
Status: Active » Closed (fixed)

I am sorry for the trouble you had to go..

The callback has to be defined in a custom module or theme code (template.php). The reason is that when doing the ajax call, template files (*.tpl.php) are not being loaded on the server, and the functions defined there are not to accessible.

I have updated the README to reflect this finding.

Thanks!