Using Hype Data Magic for dynamic ads, utilizing built-in and custom handlers

Sample-Ads-with-Hype-Data-Magic.hype.zip (208,2 KB)

3 Likes

Hi Max, first of all the Data Magic is incredible. Congrats!

I have a question, is it posible to edit the color of the tabs, or/and turn them on/off?

Thanks for all your contributions to Hype!

2 Likes

Yes, that would be done with custom handlers. Be aware that custom handlers need to reside in a script file for the preview of them to work (if you need a preview, that is). This is due to the “bug” that Hype sadly escapes certain characters in Head HTML, making code executed there in those circumstances unusable.

Here is a simple handler:

HypeDataMagic.addDataHandler('tabBackground', {
  DataMagicPrepareForDisplay: function (hypeDocument, element, event){
    if (event.data === 'true') { 
      element.style.backgroundColor = 'green';
    } else {
      element.style.backgroundColor = 'red';
    }
  }
});

Depending on the use case, you can also use Hype Reactive Content, which works nicely with Hype Data Magic. In this library, you don't have a preview, and it works with custom dynamic data.

2 Likes

Thanks Max, you are the best!