Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

template image path


3 Posts   3769 Views


8 March 2011 at 9:38pm Community Member, 3 Posts


I'm just starting up with SilverStripe and I have a question about the image-path in templates, maybe a logo or something other that does'nt hange.

I do my own template with an image inside of it.

What is the relative path URL to my own template-images-folder? Did you have a image - variable for it, or, how does it work?

<img src="images/image.png" alt="" title="where's my image???" />
From where must be set the relative path, from root does not work?

Thanks, kazuhisa


8 March 2011 at 10:34pm Forum Moderator, 1796 Posts

If the control you are in

class MyDataObject extends DataObject {
$has_one = array('MyImage' => Image);

you can...

<% control MyDataObject %>
<% control MyImage %><img src="$URL" alt="$Title" /><% end_control %>
<% end_control %>

or if the image is in the theme dir or mysite folder...

<img src="{$BaseHref}/images/myimage.png">
<img src="$ThemeDir/images/myotherimage.png">


8 March 2011 at 10:46pm Community Member, 3 Posts

Thanks a lot, I'm just find where I'm looking for:
[url=]inline css in template[/url] because I had the same question about the css-path.

Thanks for your answer, $ThemeDir does work fine.