MyBB Community Forums

Full Version: headerinclude Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Well, lately I've been having issues with my headerinclude template, and I'm not sure why.

It's not loading the scripts I've put in it, though it used to work. It's been random and scripts have stopped working one by one over the past week Sad

I've cleared my cache, CloudFlare's cache, disabled the JS minifier and all that, but nothing.

The {$headerinclude} variable is there in the index template, I've tried specifying it in the header template and that didn't work, and the really weird thing is that if I copy the scripts to the header template everything works Huh
I just checked your website and I didn't see anything abnormal. Collapsing the forums worked perfectly fine. What exactly doesn't work?
(2011-07-23, 07:52 PM)faviouz Wrote: [ -> ]I just checked your website and I didn't see anything abnormal. Collapsing the forums worked perfectly fine. What exactly doesn't work?
Everything else works, which is another weird thing. It's stuff like the Select All script for the code boxes, the Project Wonderful Ad Loader, the Adf.ly link converter, and the Google +1 button script.

And no I am not running an adblocker in my browser on the site, and the same issue showed up in Opera and Firefox.
Looks like a conflict between jQuery and the default MyBB JavaScript files. In your headerinclude template find:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

Replace with:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>

(hope you don't mind me updating your jQuery Toungue)
The only time jQuery is called afaik is when jSnippets is loaded in headerinclude and it does have noConflict set.

And by the way, 1.6.2 makes everything related to jSnippets stop working.

Also, the MyBB JS files work fine, if you would read the post it's the external scripts and that select all code, and they stopped working script by script over the past week while browsing on both my computers.
Ok, hold on right there. I checked your website again and I was able to +1 a thread just fine. The Project Wonderful ad is showing up too. This is starting to look like an issue on your end. But how come jQuery 1.6.2 breaks things? That doesn't really make much sense. Can you please post the contents of your headerinclude template?

And by the way, the select all code is part of MyBB's JavaScript files...
(2011-07-23, 08:27 PM)faviouz Wrote: [ -> ]Ok, hold on right there. I checked your website again and I was able to +1 a thread just fine. The Project Wonderful ad is showing up too. This is starting to look like an issue on your end. But how come jQuery 1.6.2 breaks things? That doesn't really make much sense. Can you please post the contents of your headerinclude template?

And by the way, the select all code is part of MyBB's JavaScript files...

Things are working because I put the scripts in the header template as I said in the original post.
And I know that, but it only works if I put the code in the header template.

If it really helps, then here's my headerinclude template:
{$stylesheets}
<style type="text/css">
@font-face {
 font-family: HandelGothic;
 src: url("fonts/HANDGOTN.eot") /* EOT file for IE */
}
@font-face {
 font-family: HandelGothic;
 src: url("fonts/HANDGOTN.TTF") /* TTF file for CSS3 browsers */
}
</style>
<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" data-cfasync="true" src="{$mybb->settings['bburl']}/jscripts/mybb.js?ver=1600"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/fastrep.js"></script>
{$retrn['master_snippet']}
{$retrn['sniplist']}
{$retrn['last_snippet']}

<script type="text/javascript">
<!--
	var cookieDomain = "{$mybb->settings['cookiedomain']}";
	var cookiePath = "{$mybb->settings['cookiepath']}";
	var cookiePrefix = "{$mybb->settings['cookieprefix']}";
	var deleteevent_confirm = "{$lang->deleteevent_confirm}";
	var removeattach_confirm = "{$lang->removeattach_confirm}";
	var loading_text = '{$lang->ajax_loading}';
	var saving_changes = '{$lang->saving_changes}';
	var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
	var my_post_key = "{$mybb->post_code}";
	var imagepath = "{$theme['imgdir']}";
// -->
</script>
{$newpmmsg}
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19164498-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<script language="javascript" type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/myadvertisements.js"</script>
<script type="text/javascript">
function selectCode(a)
{
   var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
   if (window.getSelection)
   {
     var s = window.getSelection();
      if (s.setBaseAndExtent)
     {
        s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
     }
     else
     {
        var r = document.createRange();
        r.selectNodeContents(e);
        s.removeAllRanges();
        s.addRange(r);
     }
   }
   else if (document.getSelection)
   {
     var s = document.getSelection();
     var r = document.createRange();
     r.selectNodeContents(e);
     s.removeAllRanges();
     s.addRange(r);
   }
   else if (document.selection)
   {
     var r = document.body.createTextRange();
     r.moveToElementText(e);
     r.select();
   }
}
</script>
<!-- Project Wonderful Ad Box Loader -->
<!-- Put this after the <body> tag at the top of your page -->
<script type="text/javascript">
   (function(){function pw_load(){
      if(arguments.callee.z)return;else arguments.callee.z=true;
      var d=document;var s=d.createElement('script');
      var x=d.getElementsByTagName('script')[0];
      s.type='text/javascript';s.async=true;
      s.src='//www.projectwonderful.com/pwa.js';
      x.parentNode.insertBefore(s,x);}
   if (window.attachEvent){
    window.attachEvent('DOMContentLoaded',pw_load);
    window.attachEvent('onload',pw_load);}
   else{
    window.addEventListener('DOMContentLoaded',pw_load,false);
    window.addEventListener('load',pw_load,false);}})();
</script>
<!-- End Project Wonderful Ad Box Loader -->
<script>
var adfly_id = 603491;
var adfly_advert = 'int';
var exclude_domains = ['enigmachs.com', 'twitter.com', 'google.com', 'https://apis.google.com', 'stumbleupon.com', 'facebook.com'];
</script>
<script src="http://adf.ly/js/link-converter.js"></script>

Also note that everything after myadvertisements.js is in the header template. And before you say "Dude it's myadvertisements.js!", putting that after the scripts did not work either. Another thing, everything used to work as it is now without me having to put the code in the header template.

The +1 button script is loaded right before the button instance, so there's no longer an issue there.

I'll remove the code from the header template for now and you let me know if the things I mentioned work. Be sure to clear your cache.

The weird thing is that the PW box seems to be working and so does Adf.ly. But the select all for the code box isn't working: http://enigmachs.com/thread-testing-java...-functions
When you say "everything used to work as it is now without me having to put the code in the header template", you must have done something to make it stop working. The code wouldn't just stop working by itself.

And I'm getting a little bit confused. First you said everything worked besides "the Select All script for the code boxes, the Project Wonderful Ad Loader, the Adf.ly link converter, and the Google +1 button script". And now it all works besides the Select All script? (which happens here too) How so? Did you edit anything? Or am I just misunderstanding you? Toungue

I also don't quite understand the myadvertisements.js thing. I asked you for your headerinclude template, but apparently half of it is in another template. What's the deal with that? I'm sorry but you really need to explain things a little better and simpler...
Ok, all the scripts after the myadvertisements.js line were cut and pasted into the header template, and then everything related to said scripts started working again.

And no, I didn't edit anything related to that code itself, everything was done with the clipboard Toungue

I don't know why you think half of it is in another template Huh