Jump to content
View in the app

A better way to browse. Learn more.

Learn more

Can I feature a randomised post from an information forum

Featured Replies

I want to use a widget to feature a link and snippet to randomized post from an information forum, that will change each visit (or even just daily) for my members to click and read..

But I have only been able to do the latest post in the forum.

Does anyone know how to achieve this?

    <script>
        // 1. Set your range here
        var min = 1;
        var max = 12345; // Change this to your highest topic ID

        // 2. Calculate the random number immediately
        var randomId = Math.floor(Math.random() * (max - min + 1)) + min;

        // 3. Find the link and update its destination
        var linkElement = document.getElementById('my-random-link');
        linkElement.href = "https://yourwebsite.com/index.php?app=forums&module=forums&controller=topic&id=" + randomId;
    </script>

Something maybe like a random number generator.

I would have to do some additional research to pull the maximum topic ids and if you want permissions to be involved as well.

  • 2 weeks later...
  • Author

Thanks for your reply, I will try this out! 👌

Recently Browsing 0

  • No registered users viewing this page.

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.