0

I am trying to add an affiliate script to my Drupal 7 website. I am doing this in a custom block.

Specifically, I create a block, select the scripts text format in my WYSIWYG Editor, add the script and save. I then add the block to the page I want.

This seemed to work for a few months and then suddenly, it disappeared and stopped working (probably due to an update).

The script has the below format:

<script src="https://sbhc.portalhc.com/123456/searchbox/234567"></script>

I have tried adding the code using all text formats (Plain Text, Scripts, Full HTML etc.). I've also tried adding it using one text format and then switching to another. I've also tried adding it through the Source button on the WYSIWYG editor.

As confirmed above, the script did work for a few months before disappearing and no extra modules have been added. I can confirm the script is correct because I can see what it generates on the provider portal.

| improve this question | | | | |
0

If you don't want to code it manually, you can check this module JS injector which lets you inject JS code into your site.

Allows administrators to inject JS into the page output based on configurable rules. It's useful for adding simple JS tweaks without modifying a site's official theme - for example, a 'nighttime' color scheme could be added during certain hours. The JS is added using Drupal's standard drupal_add_js() function and respects page caching, etc.

This module is definitely not a replacement for full-fledged theming, but it provides site administrators with a quick and easy way of tweaking things without diving into full-fledged theme hacking.

The rules provided by JS injector typically are loaded last, even after the theme JS, although another module could override these.

| improve this answer | | | | |
  • Many thanks for your helpful response. I certainly don't want to code this manually. The script is an advert and I may want to change it frequently. Given that display of ads is one of the standard ways to monetise websites, shouldn't Drupal handle this by default and without the need of an additional module? I'm surprised that the Scripts text format isn't able to habdle this. Especially when it worked for a few months. What is the point of it then? Cheers – sp_key Mar 4 '19 at 9:59
  • No problem. If you want to use WYISWYG editor, please update your question to include which version you're using and the configuration of the full html text filter. You can screenshots of course – Ismail Cherri Mar 4 '19 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.