Closed (fixed)
Project:
Author Pane
Version:
6.x-2.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Nov 2010 at 06:35 UTC
Updated:
9 Apr 2012 at 14:52 UTC
Hi,
I created a module, and tried to re-direct the template by the following code, which is copied from Advanced Profile Kit module with the same purpose:
function advanced_profile_preprocess_author_pane(&$variables) {
if (!empty($variables['caller']) && $variables['caller'] == 'mymodule') {
// If we are calling the Author Pane, use our template.
$variables['show_template_location'] = true;
$variables['template_files'][] = 'mymodule_author-pane';
}
}
However, when I use theme('author_pane', $account, 'mymodule'), it still use author-pane.tpl.php provied by author pane moudle.
I also posted a bug report for advanced profile kit module: http://drupal.org/node/983388
Any one know how to achieve this?
Thanks.
Comments
Comment #1
michelleI'm 95% sure that's not going to work and it has nothing to do with Author Pane. The core template suggestions, which is what you are invoking, works with themes, not modules. You need to put your template file in your theme.
Michelle
Comment #2
foredoc commentedGood to know this. I just copied mymodule_author-pane.tpl.php into my theme directory, and cleared the cache, however, it still points to author-pane.tpl.php, provided by author pane module.
Any thing else I am missing here?
Thanks
Comment #3
michelleTry fiddling with hyphens vs underscores in both the file name and the template suggestion. I know that can be tricky. I don't know anything else right offhand. This is dealing with the core theme system and I haven't had my head in that in quite some time.
Michelle
Comment #4
foredoc commentedI looked into theme.inc, function theme(){...}, and found the following piece:
In my case, $suggestions is correctly set, and has "mymodule_author-pane" as element, however, $info['theme paths'] only contains the author-pane path:
Since I put the mymodule_author-pane.tpl.php in my theme directory, it can not find the suggestion. If I copy mymodule_author-pane.tpl.php into :
sites/all/modules/contributed/author_pane
It works as what I want.
But I think the right way is to add current theme path to $info['theme paths'], not sure how to do this yet.
Thanks
Comment #5
michelleSetting this active because I'm not sure what's going on here and why your theme isn't in the paths but I don't have time to dig into it now.
Michelle
Comment #6
michelleDid you ever figure this out? I'm gearing up for a 2.1 release and trying to make sure I've got all the kinks out.
Michelle
Comment #7
paolomainardi commentedSame problem here.
I've found some solutions:
1) The only file available to override is "author-pane.tpl.php" the other one is totally ignored (tested with Zen subtheme and Garland), probably you have some chances to add some template_files using a preprocess of _author_pane function.
2) I've just added this snippet to my zen subtheme:
Forcing 'theme paths' to my template directory, permits to Drupal to use "advanced_profile_author-pane" as a template override file..
Probably is not enough this:
Probably there is need to use hook_registry_alter() ?
Comment #8
paolomainardi commentedAnother solution, but i'm not so sure is this:
hook_theme_registry_alter() is a strange beast, probably someone knows that better than me.
However this 3 lines permits to use 'advanced_profile_author-pane' as an override.
Comment #9
michelleI just tested this and it works fine.
I put this in my "sitemods" module:
Added author-pane-custom.tpl.php to t the root of my theme.
Call it by:
Showed up just fine.
@paolomainardi: All that registry alter stuff is only needed if you are trying to store the template file in your module because Drupal won't look there for it. APK used to do that so I could just refer to the included AP template but I took that all out and just tell people to copy the template to their theme because it's a a lot simpler.
Michelle
Comment #10
paolomainardi commentedDear MIchelle,
Thanks a lot for your test.
I'm just using flat "advanced_profile" module and Garland theme and only copying "advanced_profile_author-pane.tpl.php" inside template folder not works.
It's simply ignored and i can override only "author_pane" template.
Comment #11
michelleI just tested that as well and confirmed that works, too. Make sure you still have 'advanced_profile' in the AP content type settings in your user page variant. Other than that, I don't know what to tell you. It's working fine for me.
Michelle
Comment #12
paolomainardi commentedYes, it was the first thing i've checked and caller is correctly set to "advanced_profile", while the function is correctly called and template suggestions updated as well.
Seems that i've the same problem of @feredoc user and the only solution is altering 'theme paths' in order to be searched by Drupal.
I think there is a bug somewhere that cause this kind of problem, did never happen before ?
Comment #13
michelleIf you can find some way to reproduce the problem, let me know. Otherwise, I have no more ideas for you. It's working for me on 3 different dev/test sites as well as my live site, which is completely separate. It's also working for the other 7500 sites using APK unless they're being awfully quiet about it. So it sounds like something unique to your site is interfering and I have no idea what that might be.
Michelle
Comment #14
paolomainardi commentedThanks Michelle for your time and test.
I'll try to reproduce the bug, i will keep you updated.
Comment #16
lias commentedJust wanted to add that you need to have both the author-pane.tpl.php and the advanced_profile_author-pane.tpl.php files in your theme directory in order to override the display. You can then modify the advanced profile author pane file and your changes should display after clearing cache. This is for 6x and will change for 7x.