Hard-coding images into block templates
Permalink 1 user found helpful
I need to include an image in a custom block template. To locate the image (which I've placed in an 'images' folder with the template) I'm using this PHP:
echo str_replace($_SERVER['DOCUMENT_ROOT'], '', $this->getBlockPath()) . '/templates/templatename/images/image.png'
Am I missing a neater way to do this or is this the best solution?
Joe
echo str_replace($_SERVER['DOCUMENT_ROOT'], '', $this->getBlockPath()) . '/templates/templatename/images/image.png'
Am I missing a neater way to do this or is this the best solution?
Joe
I've also tried dynamically outputting the current template name so that doesn't need to be hardcoded in the path, but could never get it to work so as far as I know the above code is the simplest/best way to go.