Overriding parent theme's topic.js file

Started by franhaselden, October 15, 2018, 08:53:28 AM

Previous topic - Next topic

franhaselden

I was under the impression that, as with templates, simply placing a new version of a .js file in my theme's script dir would override the default SMF version of the file and use mine instead.

I want to change the way that the expandThumb function works, so I copied the topic.js file where this function resides and placed it in my theme's script dir, but it seems to still be using the default version.

Is there a place where I need to reset the path that it's pointing to?

Arantor

If memory serves you basically need to hack the code that loads the file, there is no way other than that to override the JS files.

Look at your theme's index.template.php, the call should be in there.

franhaselden

Can't find any reference call to topic.js in index.template.php - hmm. I'll have to pull down the full theme and search

Arantor


franhaselden

No, but when I look at the source code, topic.js script seems to be inserted in an odd location (I'd have expected either in the head or at the end of the page, but it's inserted just after the quickReply box).

I'll look through the other template files and see if I can find it.

franhaselden

Found it in the bottom of the Display template. I'm guessing this is so it is only loaded on topic pages.

For anyone stumbling across this, I'm using Reseller theme and located it in my Display template file. The code includes /scripts/topic.js, but it's pointing to the default theme.

Original:

<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/topic.js"></script>

My change:

<script type="text/javascript" src="' . $settings['actual_theme_url'] . '/scripts/topic.js"></script>

Advertisement: