API page: http://api.drupal.org/api/drupal/modules--system--page.tpl.php/7
Describe the problem you have found:
There is a discrepancy between Drupal 6 and Drupal 7 and with the documentation of Drupal 7 with regards to the $directory variable.
In Drupal 6, when you have a theme called for the purpose of this example base_theme with a page.tpl.php and have a link to an image in this form: <img src="<?php print $base_path . $directory; ?>/images/image.jpg" alt="" /> and create a theme that inherits this base_theme and its page.tpl.php, the path returned for the inherited theme is the image folder of the inherited theme which allows for override of the base theme.
However, in Drupal 7 the path returned is that of the base_theme and not the inherited theme.
I personally prefer the Drupal 6 approach and I am wondering if this is a bug in Drupal 7 or if the behavior has changed and was not updated in the documentation?
Thanks!
Comments
Comment #1
aspilicious commentedBugs are fixed first in latest dev release of drupal.
Adding the needs documentation tag so the doc people notice it.
I don't know if it is a bug or not.
Comment #2
jhodgdonSounds like this is something that needs to be documented in the update guide for D6/7 for theming. Not sure why it was in the token component.
Comment #3
LaurentGoderre commentedI wonder why it changed if it worked perfectly well in Drupal 6....
Comment #4
damien tournoud commentedSee #1026156: path_to_theme() isn't clear about which path it returns.
Comment #5
jhodgdonActually, this isn't a duplicate. This issue is about adding update docs for d6/7 for the $directory variable in page.tpl.php. That other issue is about fixing the doc for the path_to_theme() API function in d7/8. They are related, but not the same issue.
Comment #6
LaurentGoderre commentedFor simplicity sake though, directory should be a simple as it gets to use....returning the folder of the current theme... I don't think theme developers want to know about the inner logic etc..they just want that path, invariably pointing to the right place regardless of theme nesting or other factors.
Thoughts?
Comment #7
LaurentGoderre commentedThis code did the job for me:
Comment #8
jhodgdonIf you want to request a change to what is in the $directory variable, please file a different issue against Drupal 8. This issue is currently about documenting the change between drupal 6 and 7.
Comment #9
LaurentGoderre commentedSorry. It seems that Drupal 6 actually has the same problem so this issue can be closed. It all depends on the file structure etc.
That being said, both the Drupal 6 and 7 documentation need to be changed to outline the unpredictable nature of that variable.