• While creating requests or asking for support in the existing XenForo threads please maintain XenForo support policy strictly.

  • You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Display a notice in specific threads or forums

rojo_salas

Well-known member
Babiato Lover
Trusted Uploader
May 2, 2022
200
357
70
92.119.176.178
nano.rojosalas.com
Source: Xenforo Official Community



Out of the box, there is no specific thread criterion for notices.

However, it's very simple to achieve.

Step 1
Create the notice as follows:
1608145532337-webp.242290


Here I am using a custom CSS class name of ctaThread3 in the Message div and the Display styling: Other, using a custom CSS class name field.

You can name yours whatever you wish but ensure it is unique and doesn't clash with any other classes and is the same in both locations.

You can omit the notice--primary from the display styling field if you want to completely customize the appearance of the notice.

Step 2

Then, in the extra.less template add this:

CSS:
.ctaThread3
{
display: none;
}

[data-content-key="thread-3"]
{
.ctaThread3
{
display: block;
}
}

Change the 3 in the [data-content-key="thread-3"] line to the actual thread ID.

Make sure you keep the entries in that order and that the ctaThread3 class name matches what you used in the notice.

Apply any custom styling after the display: block; line as required, for example.:
Less:
CSS:
[data-content-key="thread-3"]
{
.ctaThread3
{
display: block;
color: orange;
font-weight: 600;
}
}
That's it!

If you want to show the notice in more than one thread, enter additional data elements, like so:

You can even use different data elements - this will show the notice in two different threads, and one forum:

The same approach can be used for any page that has a unique [data-...] key, such as a specific forum -- data-container-key="node-1" -- or resource category -- data-container-key="xfrmCategory-43".


The key can be obtained using the browser inspector (F12) and checking the <html ... > line.
Opera Snapshot_2024-03-25_192228_enxf.cc.png
Opera Snapshot_2024-03-25_192237_enxf.cc.png

If you found this tutorial useful, donations of positive emojis are gladly received.
 
Last edited:
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock