Closed (works as designed)
Project:
Drupal core
Version:
6.3
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Apr 2008 at 03:40 UTC
Updated:
22 Oct 2010 at 12:10 UTC
When I use this function in my custom module. It return "modules/system". Weird, it must be a bug.
Comments
Comment #1
boaz_r commentedYep, same for me. Exactly (although that it happens on D6.1 in my case). I reverted to using $base_url + "/sites/all/themes..." which is bad practice, but working for now.
Boaz.
Comment #2
DrewMathers commentedOn Drupal 6.1, I find that path_to_theme() consistently returns the value of the previous theme used. I thought this might be a caching issue, but calling cache_clear_all() immediatly before path_to_theme() made no difference.
[Edit] Please disregard the above comment. It was a result of my logic error. My path_to_theme() works fine.
Comment #3
brainski commentedI have the same problem. Also the global variable $directory shows the path to my custom module.
How to find out the path to my theme?
Comment #4
mrfelton commentedsame here. I'm getting this problem when trying to use path_to_theme() in a node template file used to style stuff output by the views module. I'm trying to use it in /mytheme/contemplate/node-mycontenttype-teaser.tpl.php, but it just outputs /sites/mysite/modules/views, rather than the path to my actual theme directory (which should be /sites/mysite/themes/mytheme)
Comment #5
prosk commentedWhat error? I m experiencing the same problem. Maybe we have the same logic error??
Comment #6
zigmoo commentedHey Guys,
Thanks for posting and thus helping me figure out/fix my own problem. My issue came up when I was creating a new theme (I's a total noob at this) based on a pre-existing theme. Essentially, having two files named themeName.info and containing the same content understandably threw Drupal for a loop!
In the case where a theme's .info file seems to occur twice (once in the old theme, and once more in the new copied theme), Drupal is unable to recognize the duplication issue, and so it only appears the the path_to_theme() is malfunctioning, when in fact, it's pointing to the only occurrence of the theme path that it knows about.
So, my solution/fix was to simply remove the duplication issue by completing my new theme, which was accomplished by removing the old themeName.info file and replacing it with a new one, unique to the new theme.
Hope this helps,
moo
Comment #7
kanani commentedIn Drupal 6.4 setting the $base_url in settings.php solved the problem.
Comment #8
aaron commentedThis is probably related to #194098: path_to_theme() returns path to module that calls it.
Comment #9
bradweikel commentedI concur. While this is not a duplicate of the original issue in #194098: path_to_theme() returns path to module that calls it, the discussion there resulted in a documentation clarification at http://api.drupal.org/api/function/path_to_theme :
"If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the active theme."
This addresses the general issue, and particularly the case mentioned in comment #4.
Comment #10
arielberg commentedworkaround - drupal_get_path("theme","mythemename");
Comment #11
matteogeco commentedMore refined workaround:
;-)