Jump to:

1347 Posts in 439 Topics by 514 members

Themes

SilverStripe Forums » Themes » Creating portable links

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 1330 Views
  • thepurpleblob
    Avatar
    Community Member
    28 Posts

    Creating portable links Link to this post

    I am developing a new theme with some images in it. What I need to do is to include img tags to images that are located in a sub-directory of the theme.

    I need the theme to be portable but I'm unsure how to specify the URL of the image. It's easy enough if the silverstripe install will always be at the top level, but it won't. Is there a variable I can access in the template to specify the 'root' of the install or is there a simpler and/or more sensible way to do this?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Creating portable links Link to this post

    You can use urls that are relative to the SilverStripe directory, since SilverStripe uses the <base href=""> attribute for all pages.
    So something like <img src="themes/yourtheme/subfolder/image.png" /> should work.

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: Creating portable links Link to this post

    or $ThemeDir/subfolder/yourimage.jpg

  • thepurpleblob
    Avatar
    Community Member
    28 Posts

    Re: Creating portable links Link to this post

    Ahh cool.... $ThemeDir... right there in the tutorial page (now I know what to look for) but not, unfortunately, in the Page Controls documentation where I was looking.

    Great. Thanks

    1330 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.