Announcement

Collapse
No announcement yet.

Random Song of the Day

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Random Song of the Day

    Okay, technically, random song whenever the page is loaded, but it adds a nice effect to websites.
    While not a new concept by any means, this code will let one add music to their forum.

    Activate the Site Builder
    Add a Static HTML Module
    Edit the module
    Click image for larger version

Name:	Clipboard01.jpg
Views:	371
Size:	61.4 KB
ID:	1146

    Add this code.
    The vb conditional code ensures that the player only appears to registered users logged into the forum.
    You can build your list as long as you like, you just have to make a few adjustments.
    /Media_Server/Song_of_the_Day/ sets the location of your mp3 files.
    The variables set the name of the mp3's. Don't use spaces or special characters.
    You will also have to add more X= values. Note that the X value uses zero.
    Also, if you do not want the music to start on load, then change autoplay="" to autoplay="false"

    Code:
    <!-- Start Background Music Player -->
    
    [COLOR=#FF0000]<vb:if condition="is_member_of($user, 2)">[/COLOR]
    <center>
    <script>
    <!--
    [COLOR=#00FF00]var sound1="Brazil.mp3"
    var sound2="Big_Balls.mp3"
    var sound3="Night_Life.mp3"
    var sound4="Kiss.mp3"
    var sound5="Futures.mp3"[/COLOR]
    var x=Math.round(Math.random()*4)
    if ([B]x=[/B]=0) x=sound1
    else if (x==1) x=sound2
    else if (x==2) x=sound3
    else if (x==3) x=sound4
    else [B]x=[/B]sound5
    document.write('<audio [B]autoplay=""[/B] controls="" preload=""><source src='+'"[COLOR=#0000CD]/Media_Server/Song_of_the_Day/[/COLOR]'+x+'"'+'type="audio/mpeg"></audio>')
    //-->
    </script>
    </center>
    
       [COLOR=#FF0000] </vb:if>[/COLOR]
    
    <!-- End Background Music Player -->

    Save and reload.
    The player will look slightly different in various browsers.
    This is how it appears in Firefox.

    Click image for larger version

Name:	Clipboard02.jpg
Views:	127
Size:	11.2 KB
ID:	1147

    #2
    vB conditional code does not work in Static HTML module. You have to use an Ad module which allows conditional code.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      Originally posted by glennrocksvb View Post
      vB conditional code does not work in Static HTML module. You have to use an Ad module which allows conditional code.
      Hmmm, works just fine for me, as the snapshots show.
      Module HTML.
      Song player shows when logged into the forum.
      When logged out, it doesn't show.
      Tested to work on vB5.1.0 - 5.2.1

      If you use an Ad module, since vB broke them back in what was it 5.1.0, it can screw up your SQL database, and it doesn't appear the same. Often without collapse controls.

      Comment


        #4
        Maybe it works for you because as you said your site was "heavily modified with my own PHP code throughout"?
        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #5
          Originally posted by glennrocksvb View Post
          Maybe it works for you because as you said your site was "heavily modified with my own PHP code throughout"?
          It is certainly possible. If so, I should try to locate the change and post it. Would benefit users as I see a lot of them asking how can I hide this or that from guests.
          7PM here and I'm working the grill.
          Will check the Module code out later and get back on this.
          Contrariwise, why is it you think the conditional will not work? Just curious.

          Comment


            #6
            Ah, you were correct. The widget fails to use the vb conditional as is. Something I changed, according to my notes, about 2 and a half years ago.
            In Templates, widget_statichtml, I added <vb:if condition="is_member_of($user, 2)"> as the first line and </vb:if> as the last line. THIS prevents guests from seeing the module.
            That makes the ones in the code redundant. I left it there in the event vB ever fixed its widget, but they never did.

            Comment


              #7
              Static HTML module is only intended to use static HTML as its name implies. It is by design vB code conditional is not supported in HTML modules. I'm not sure if vB will ever change that design. If ever they implement the usergroup permission check, it would be for all modules (not just HTML module) and it would be in module configuration.
              Helpful? Donate. Thanks!
              Buy me a coffeePayPal QR Code
              Fast VPS Host for vBulletin:
              A2 Hosting & IONOS

              Comment


                #8
                Originally posted by glennrocksvb View Post
                If ever they implement the usergroup permission check, it would be for all modules (not just HTML module) and it would be in module configuration.
                That's a tree I've been barking up for years now, that they should do ALL modules with permissions. Especially given the ones without are at severe risk of exploitation by non-members/unregistered users, and, because so many people request to be able to block modules from guests.
                Its sort of like putting a big ol' lock on the front door but leaving the windows wide open and calling the house secure.

                Comment


                  #9
                  You all should vote for this feature to help make this happen.



                  You could also comment on that JIRA entry to make your opinions heard.

                  Felix2 I totally agree with your comments and rants but if they are not directed towards who can make this happen, then you're barking on the wrong tree.
                  Helpful? Donate. Thanks!
                  Buy me a coffeePayPal QR Code
                  Fast VPS Host for vBulletin:
                  A2 Hosting & IONOS

                  Comment

                  Users Viewing This Page

                  Collapse

                  There is 1 user viewing this forum topic.

                  • Guest Guest

                  Latest Posts

                  Collapse

                  Working...
                  X
                  Searching...Please wait.
                  An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

                  Please push the back button and reload the previous window.'
                  An unexpected error was returned: 'Your submission could not be processed because the token has expired.

                  Please push the back button and reload the previous window.'
                  An internal error has occurred and the module cannot be displayed.
                  There are no results that meet this criteria.
                  Search Result for "|||"