Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding Links to CSS in customised theme

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

Page: 1
Go to End
Author Topic: 1292 Views
  • CHKM
    Avatar
    Community Member
    7 Posts

    Adding Links to CSS in customised theme Link to this post

    Hi all,

    I'm a new user to SS but loving it so far, it seems to be perfect for multiple sites I host.

    I have started writing my current websites themes and got everything working appart from one thing;

    I cannot for the life of me get it to find image links to work in the CSS, I'm pretty sure its a syntax problem..

    I'm currently storing them in

    theme_name/images

    and addressing them in the CSS as the guide states as

    background: #fff url('$ThemeDir/images/intro.jpg') no-repeat;
    (for example)

    I was wondering if anyone could correct me on the correct way to do this please?

    Thanks in advance to any help, I'm looking forward to using SS ^^

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Adding Links to CSS in customised theme Link to this post

    assuming: themes > your theme > css, images, templates

    then,
    background: #fff url('../images/intro.jpg') no-repeat;

  • CHKM
    Avatar
    Community Member
    7 Posts

    Re: Adding Links to CSS in customised theme Link to this post

    Thanks, thats exactly what i did in the end. I'm still not sure how the tutorial intends it to work, but it works fine that way

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: Adding Links to CSS in customised theme Link to this post

    Could you please point to the page of the guide stating that you can use $ThemeDir in a CSS file? I can’t believe it.

    Regards,
    Juan

  • socks
    Avatar
    Community Member
    190 Posts

    Re: Adding Links to CSS in customised theme Link to this post

    There's info in the API and I just learned something new.
    You can use that in your template.ss files.

    ThemeDir (line 859)
    Returns the root directory of the theme we're working with.

    This can be useful for referencing images within the theme. For example, you might put a reference to <img src="$ThemeDir/images/something.gif"> in your template.

    If your image is within a subtheme, such as mytheme_forum, you can set the subtheme parameter. For example, <img src="$ThemeDir(forum)/images/something.gif">

  • CHKM
    Avatar
    Community Member
    7 Posts

    Re: Adding Links to CSS in customised theme Link to this post

    Yes, after a bit more learning (and developing) I now see I totally misunderstood its purpose, its for use in .ss only and not all ss files as I thought!

    So the tutorial is perfect I just need my brain checking! Sorry for the false alarm

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