Photo of Trey Hendon III

0

Custom Theme

I'm working on my first custom theme (a copy of Stark).  I'm wondering if anyone has found a way to keep the links to the Theme's files completely relative?  I see this code in the Site.Master file:

<link rel="stylesheet" href="<%# ResolveRockUrl("~/Styles/theme.css", true) %>"/>

The problem I seem to be having is that it is resolving to http://myurl.com/Styles/theme.css not http://myurl.com/Themes/myCustomTheme/Styles/theme.css.  Am I missing something?

I'm asking this question becuase I believe it will help me solve my core issue - loading a custom CSS file after the theme.css file and having conflicting CSS issues.

CSS
  • Photo of Rock RMS

    0

    In .net the tilde (~) will resolve to the application root when used in a resolving function. In Rock we added support for a double-tilde (~~) to resolve to the current theme's folder. So:

    <link rel="stylesheet" href="<%# ResolveRockUrl("~~/Styles/theme.css", true) %>"/>

    Would resolve to '/Themes/myCustomTheme/Styles/theme.css'

    Is this what you're looking for?

    • Trey Hendon III

      I had a spark of a memory when I saw something else using the double-tilde and gave that a shot. Just a thought, it might be worth changing Stark to use the double-tilde for all it's file.

  • Photo of Trey Hendon III

    0

    Sorry to answer my own question, but I figured it out.

    "~" vs "~~" is the key.  A single "~" will link to the current site's top domain (relative to a virtual director if applicable).  A double "~~" will link to the relative folder above the current file's location.