Jump to content
View in the app

A better way to browse. Learn more.

Invision Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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.

Account

Navigation

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.