Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Scenario:
- I create an Omega subtheme
- I place a file zone--postscript.tpl.php
in the templates folder;
content of that file:
<?php
/**
* @file
* Adding an image to the postscript zone
*/
?>
<div class="decoratie"><img src="<?php print $base_path . $directory; ?>/images/opleuken.jpg" /></div>
<?php if ($wrapper): ?><div<?php print $attributes; ?>><?php endif; ?>
<div<?php print $content_attributes; ?>>
<?php print $content; ?>
</div>
<?php if ($wrapper): ?></div><?php endif; ?>
- in the html rendered I get:
<img src="sites/**.****.nl/themes/omega/alpha/images/opleuken.jpg">
So <?php print $base_path . $directory; ?>
refers to ../themes/omega/alpha
??
Comments
Comment #1
Argus CreditAttribution: Argus commentedThe question remains, but of course it's easier to add an image on top above the postscript regions the Omega Way:
- Add a region to the postscript zone (in the yourtheme.info for instance add
regions[postscript_pre] = 'Postscript Pre'
).- Clear Cache.
- Assign the region to the postscript zone, in my case I gave it a weight of zero so it would appear above the other regions in the postscript zone.
- Add a block with the image to that region.
This will take care of all the formatting for you, all margins and padding are taken care of. It does generate a little more HTML.
Comment #2
knalstaaf CreditAttribution: knalstaaf commentedThe use of an extra region would be a little too much in my case. I just need to position a small image somewhere in the menu region, on the right of the menu. This isn't self evident because the menu is not positionable through the Block administration.
So indeed, if someone could pass through a little line of code that renders the path to the subtheme files, it would fill my heart with joy.
Comment #3
marcoka CreditAttribution: marcoka commentedbase_path is core.
http://api.drupal.org/api/drupal/developer!globals.php/global/base_path/7
i do not know where $directory comes from. seems its the path to sites/**.****.nl/themes/omega/alpha/
Comment #4
bc CreditAttribution: bc commented#1026156 explains why this happens
Comment #5
Argus CreditAttribution: Argus commentedThat would be #1026156: path_to_theme() isn't clear about which path it returns ?
Comment #6
bc CreditAttribution: bc commentedyes, that one :)
i've taken to doing drupal_get_path() instead.
Comment #7
himerus CreditAttribution: himerus commentedyes, drupal_get_path is the appropriate method.