[3.2][BETA] Custom Code

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Get Involved
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
martti
Registered User
Posts: 754
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] Custom Code

Post by martti » Thu Feb 14, 2019 10:55 pm

John connor wrote:
Thu Feb 14, 2019 10:35 pm
Question: I rely on this extension right now for a lot of things. When phpBB updates to version 4, do you think this extension will still work? I have added a lot of footer stuff and I'd like to keep it there. Then during Christmas I have code on the index that randomly plays a Christmas audio clip.
4? I'm unaware about that. Are they working on version 4 at the moment?

User avatar
david63
Registered User
Posts: 16408
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [3.2][BETA] Custom Code

Post by david63 » Thu Feb 14, 2019 11:18 pm

John connor wrote:
Thu Feb 14, 2019 10:35 pm
Question: I rely on this extension right now for a lot of things. When phpBB updates to version 4, do you think this extension will still work? I have added a lot of footer stuff and I'd like to keep it there. Then during Christmas I have code on the index that randomly plays a Christmas audio clip.
As we do not know what is in phpBB 4, or even when it may appear, I doubt that at this point anyone can answer that question. My personal view is that many, if not all, extensions will not work in phpBB 4
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
John connor
Registered User
Posts: 2201
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][BETA] Custom Code

Post by John connor » Mon Sep 02, 2019 12:31 pm

What code would I use to play audio on login only? I have code that can play audio on the index which I use at Christmas, but how would I do it just on login? I don't know PHP.

User avatar
martti
Registered User
Posts: 754
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] Custom Code

Post by martti » Tue Sep 03, 2019 6:15 am

John connor wrote:
Mon Sep 02, 2019 12:31 pm
What code would I use to play audio on login only? I have code that can play audio on the index which I use at Christmas, but how would I do it just on login? I don't know PHP.
Maybe check on a template variable that comes with the login box:
(i.e in the overall_footer_page_body_after template event)

Code: Select all

{%- if S_LOGIN_ACTION -%}
Your code here
{%- endif -%}

User avatar
John connor
Registered User
Posts: 2201
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: [3.2][BETA] Custom Code

Post by John connor » Wed Sep 04, 2019 3:28 am

I used the audio code I got from you a few years ago as a test, but this doesn't seem to work. This is what I added to overall_footer_page_body_after


Code: Select all

{%- if S_LOGIN_ACTION -%}
<audio id="audio" preload="auto" tabindex="0" controls="" type="audio/ogg" style="display: none;">   
</audio>
<div id="playing" style="display: none;">
</div>
<script>
var audio;
var playlist;
var tracks;
var current;
var musicarr = ["https://www.mywebsite.com/images/bells.ogg",
                "https://www.mywebsite.com/images/bells2.ogg",
                "https://www.mywebsite.com/images/bells3.ogg",
                "https://www.mywebsite.com/images/christmas.ogg",
                "https://www.mywebsite.com/images/santa.ogg",
                "https://www.mywebsite.com/images/noel.ogg",
                "https://www.mywebsite.com/images/hoho.ogg",];
shuffle(musicarr);

init();
function init(){
    current = 0;
    audio = $('audio');
    audio[0].volume = .20;
    len = musicarr.length;
   
    run(musicarr[current], audio[0]);
   
    
}

function run(link, player){
        player.src = link;
        audio[0].load();
        audio[0].play();
        $('#playing').html("<ul><li><a>" + link+ "</a></li></ul>");     
}

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex ;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}
</script>
{%- endif -%}

That code was added to your extension inserttemplatecode.

User avatar
</Solidjeuh>
Registered User
Posts: 1703
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [3.2][BETA] Custom Code

Post by </Solidjeuh> » Wed Sep 04, 2019 1:38 pm

martti wrote:
Tue Sep 03, 2019 6:15 am

Code: Select all

{%- if S_LOGIN_ACTION -%}
Your code here
{%- endif -%}
This is not working, it's playing the sound on every page you open

Post Reply

Return to “Extensions in Development”