[3.3][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)
rrbailey89
Registered User
Posts: 248
Joined: Fri Oct 24, 2014 3:00 pm

Re: [RC] Custom Code

Post by rrbailey89 »

martti wrote:
rrbailey89 wrote:I see the content on my acp login page at the bottom left above the footer. Is this peventable? it should only be showing on the index page.
The ACP login page has also 'index' as SCRIPT_NAME. Template variable S_ADMIN_AUTH is true on the ACP login page, so you can add not S_ADMIN_AUTH to the conditional statement.

Edit : overall_footer_body_after

Code: Select all

<!-- add content in index right div in PBTech style -->

<!-- IF SCRIPT_NAME == 'index' and not S_ADMIN_AUTH-->

<div id="my-content">
    My content ...
</div>

<script>
$(document).ready( function() {
    $('div.index-right').eq(0).append($('div#my-content'));
});
</script>

<!-- ENDIF -->
Martti, again thank you. That worked! I have just one more request. Is it possible to have this div auto refresh every 30 seconds or so? I have tried adding a script like this.

Code: Select all

setInterval(function(){
    $('iframe')[0].contentWindow.location.reload(true);
}, 30 * 1000);
however I receive an uncaught exception about differences in http and https. Is there another way? Also I think the example Im trying to use will refresh any iframe so I would like a solution that refreshes the pertinent div tag/iframe only.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

rrbailey89 wrote:
Martti, again thank you. That worked! I have just one more request. Is it possible to have this div auto refresh every 30 seconds or so? I have tried adding a script like this.

Code: Select all

setInterval(function(){
    $('iframe')[0].contentWindow.location.reload(true);
}, 30 * 1000);
however I receive an uncaught exception about differences in http and https. Is there another way? Also I think the example Im trying to use will refresh any iframe so I would like a solution that refreshes the pertinent div tag/iframe only.
The function reload won't work because it's cross domain. You can try the following trick.

Code: Select all

    setInterval(function(){
                var iframe = $('iframe').eq(0);
		iframe.attr('src', iframe.attr('src'));
	}, 30000);
rrbailey89
Registered User
Posts: 248
Joined: Fri Oct 24, 2014 3:00 pm

Re: [RC] Custom Code

Post by rrbailey89 »

martti wrote:
rrbailey89 wrote:
Martti, again thank you. That worked! I have just one more request. Is it possible to have this div auto refresh every 30 seconds or so? I have tried adding a script like this.

Code: Select all

setInterval(function(){
    $('iframe')[0].contentWindow.location.reload(true);
}, 30 * 1000); 
however I receive an uncaught exception about differences in http and https. Is there another way? Also I think the example Im trying to use will refresh any iframe so I would like a solution that refreshes the pertinent div tag/iframe only.
The function reload won't work because it's cross domain. You can try the following trick.

Code: Select all

    setInterval(function(){
                var iframe = $('iframe').eq(0);
		iframe.attr('src', iframe.attr('src'));
	}, 30000);
Thank you Martti, that does indeed work. I just wish there was a way I could tell it to only refresh that specific div/iframe, incase other iframes/divs need to be added to the index page in the future.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

rrbailey89 wrote: Thank you Martti, that does indeed work. I just wish there was a way I could tell it to only refresh that specific div/iframe, incase other iframes/divs need to be added to the index page in the future.
You can add id properties to the html elements and select by id:

Code: Select all

<iframe id="iframe-1" src="http://example1.com"></iframe>

<iframe id="iframe-2" src="http://example2.com"></iframe>

<script>
var iframe1 = $('iframe#iframe-1');  /* # is used for selecting an element by id. Syntax is the same as css selectors */
var iframe2 = $('iframe#iframe-2');

/* do something with iframe1 and iframe2 */
</script>
rrbailey89
Registered User
Posts: 248
Joined: Fri Oct 24, 2014 3:00 pm

Re: [RC] Custom Code

Post by rrbailey89 »

martti wrote:
rrbailey89 wrote: Thank you Martti, that does indeed work. I just wish there was a way I could tell it to only refresh that specific div/iframe, incase other iframes/divs need to be added to the index page in the future.
You can add id properties to the html elements and select by id:

Code: Select all

<iframe id="iframe-1" src="http://example1.com"></iframe>

<iframe id="iframe-2" src="http://example2.com"></iframe>

<script>
var iframe1 = $('iframe#iframe-1');  /* # is used for selecting an element by id. Syntax is the same as css selectors */
var iframe2 = $('iframe#iframe-2');

/* do something with iframe1 and iframe2 */
</script>
So for example something like this?

Code: Select all

<div id="my-content">
<iframe id="iframe-1" src="https://discordapp.com/widget?id=**********&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0"></iframe>
<center>Refreshes Every 5 Minutes</center>
</div>

<script>
$(document).ready( function() {
    $('div.index-right').eq(0).append($('div#my-content'));
});
</script>

<script>
    setInterval(function(){
                var iframe1 = $('iframe#iframe-1');.eq(0);
      iframe.attr('src', iframe.attr('src'));
   }, 30000);
</script>
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

rrbailey89 wrote: So for example something like this?
Yes, but with some corrections:

Code: Select all

<div id="my-content">
<iframe id="iframe-1" src="https://discordapp.com/widget?id=**********&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0"></iframe>
<center>Refreshes Every 5 Minutes</center>
</div>

<script>
$(document).ready( function() {
    $('div.index-right').eq(0).append($('div#my-content'));
     setInterval(function(){
                var iframe1 = $('iframe#iframe-1');
      iframe1.attr('src', iframe1.attr('src'));
   }, 30000);   
});

</script>
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post by Solidjeuh »

Is it possible to add links/urls in the "Quick links"?
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Lumpy Burgertushie
Registered User
Posts: 68195
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: [RC] Custom Code

Post by Lumpy Burgertushie »

the quick links menu is in the navbar_header.html file

you would copy that file and add it to the collection of event template files in the extension. edit it the way you wish.

there are instructions in other posts in this topic on how to add other html files to the list in the extension etc.


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post by Solidjeuh »

Lumpy Burgertushie wrote:the quick links menu is in the navbar_header.html file

you would copy that file and add it to the collection of event template files in the extension. edit it the way you wish.

there are instructions in other posts in this topic on how to add other html files to the list in the extension etc.


robert
Thank you! I added the navbar, but now it shows 2 times..?
Image
I don't suffer from insanity. I enjoy every minute of it.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

Solidjeuh wrote:
Lumpy Burgertushie wrote:the quick links menu is in the navbar_header.html file

you would copy that file and add it to the collection of event template files in the extension. edit it the way you wish.

there are instructions in other posts in this topic on how to add other html files to the list in the extension etc.


robert
Thank you! I added the navbar, but now it shows 2 times..?
Image
So, Lumpy didn't mean you have to copy navbar_header.html, but to search for the template events inside that file. Just undo what you did.

The template event you are looking for is navbar_header_quick_links_before or navbar_header_quick_links_after. These template events are not included in the extension.
So you're options are
  • Fork the extension and add this template event yourself. (See here)
  • Or, add your links with Javascript. See below.
To add to the quick links with Javascript:

Edit : overall_footer_body_after.html

Code: Select all

<!-- append a quicklink -->

<li id="my-quick-link" class="small-icon icon-search-self">
  <a href="#">
    My link
  </a>
</li>

<script>
$(document).ready( function() {
	$('li#quick-links div ul').append($('#my-quick-link'));
});
</script>
If you want to put your link at the beginning of the list, then replace append with prepend in this code.
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post by Solidjeuh »

Ooow ok I underdstand now! Gonna try tonight!
Thank you! 8-)
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post by Solidjeuh »

Solidjeuh wrote:Ooow ok I underdstand now! Gonna try tonight!
Thank you! 8-)
Works perfect! Thank you for the help! :)
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post by Solidjeuh »

I'm learning, so 1 more question... :D
How can I place text under the reply editor with javascript?
I know it's this event EVENT quickreply_editor_message_after but don't know what code to use

Like this:

Image
I don't suffer from insanity. I enjoy every minute of it.
User avatar
martti
Registered User
Posts: 867
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post by martti »

Solidjeuh wrote:I'm learning, so 1 more question... :D
How can I place text under the reply editor with javascript?
I know it's this event EVENT quickreply_editor_message_after but don't know what code to use

Like this:

Image
For appending to the quickreply you can use this:

Edit : overall_footer_body_after.html

Code: Select all

<!-- append to quickreply -->

<!-- IF SCRIPT_NAME == 'viewtopic' -->

<div id="my-div" style="display:none;">
My content ...
</div>

<script>
$(document).ready( function() {
    var myDiv = $('#my-div');
    $('#qr_postform div.panel div.inner').append(myDiv);
    myDiv.css('display', 'inherit');
});
</script>

<!-- ENDIF -->
For appending to the full posting editor you can use this:

Edit : overall_footer_body_after.html

Code: Select all

<!-- append to posting box -->

<!-- IF SCRIPT_NAME == 'posting' -->

<div id="my-div" style="display:none;">
My content ...
</div>

<script>
$(document).ready( function() {
    var myDiv = $('#my-div');
    $('#postingbox div.inner').append(myDiv);
    myDiv.css('display', 'inherit');
});
</script>

<!-- ENDIF -->
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post by Solidjeuh »

Super! Thanks again! 8-)
I don't suffer from insanity. I enjoy every minute of it.
Post Reply

Return to “Extensions in Development”