Jump to:

3443 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » template image path

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 3664 Views
  • kazuhisa
    Avatar
    Community Member
    3 Posts

    template image path Link to this post

    Hello,

    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?

    Example:
    <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

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: template image path Link to this post

    If the control you are in

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

    you can...

    <% control MyDataObject %>
    $MyImage
    or
    <% 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">

  • kazuhisa
    Avatar
    Community Member
    3 Posts

    Re: template image path Link to this post

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

    Thanks for your answer, $ThemeDir does work fine.

    3664 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.