Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

What's the variable for the theme directory?

edited November 2011 in Vanilla 2.0 - 2.8
Trying to include some JS in my header, but I don't want to specify the name of the directory in the path, because I'm sure it will change some time.
Here's the code I'm trying to put in:
<link rel="stylesheet/less" type="text/css" href="styles.less"> <script src="less.js" type="text/javascript"></script>

script src="less.js" needs to have a path before less.js, as it's trying to load it from the forum root.

What can I use to make it load it from the theme directory?

Best Answer

  • 422422 Developer MVP
    Answer ✓
    Tutorial added. Perhaps it will help, perhaps it wont. But its free so have some fun.

    There was an error rendering this rich post.

Answers

  • jspautschjspautsch Themester ✭✭✭
    You can also include it using a theme hooks php file (e.g. class.enigmathemehooks.php):
    public function Base_Render_Before($Sender)
    {
    $Sender->AddJsFile('less.js', 'themes/enigma');
    }
  • edited November 2011
    Yes, but I don't want it depending on the current folder structure, I'd like to be dynamic. So even if the theme folder is renamed or the files are copied to another theme folder, it will work.
  • jspautschjspautsch Themester ✭✭✭
    Why would you want to do that? You really should keep all files for a theme contained within its own folder.
  • One, it would make it easier to copy the file to the different versions of the theme I'm making, and two, it will prevent problems if someone decides to rename the directory or changes the vanilla directory.
  • jspautschjspautsch Themester ✭✭✭
    That doesn't make any sense. The themes directory is always called themes, why would anyone change it? And renaming the vanilla directory doesn't matter, the AddJsFile function uses what the directory is set to.
  • I meant the directory the theme itself is in, like InterBlue. I've got color variants of that theme and I want to be able to copy the modified default.master.php file over to each one without having to edit the code.
  • 422422 Developer MVP
    edited November 2011
    Do you want to just add style switcher to the forum ?

    There was an error rendering this rich post.

  • Well I'd like to make these into separate themes, but I suppose a style switcher would fix everything. Not sure how to do that though.
  • 422422 Developer MVP
    I can code this for you , bear with me. Not sure how to integrate with forum though, but the call can be done from a sidebar panel. Give me an hour

    There was an error rendering this rich post.

  • That will be cool :) Thanks.
  • 422422 Developer MVP
    Answer ✓
    Tutorial added. Perhaps it will help, perhaps it wont. But its free so have some fun.

    There was an error rendering this rich post.

Sign In or Register to comment.