Header Addon

Started by flapjack, February 19, 2011, 12:58:56 PM

Previous topic - Next topic

flapjack

Link to Mod

Header Addon
Summary:
This mod allows to add custom code to <head> section of your forum. It's using hooks, so it will work in any 2.0 RC5 theme without manual edits.
You can use it to add additional JS files, CSS files or inline modifications.

Settings Screenshot:


Compatibility:
Compatible with SMF 2.0 RC5

Change Log:
o February 2011 - initial release 1.0

DoctorMalboro

Simple and nice. Nice job, flapjack

Masterd


syrinx75

Hello flapjack,

Is it a solution to add this code automatically in all the html page?
<HTML><HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD><BODY>
</BODY>
</HTML>


I'm looking how to to do that with SMR 1.1.13. How can I do?

Thank you for help.

Masterd

This mod is still not available for SMF 1.1.x.

flapjack

and it won't be available for 1.x as there's no hooks mechanism there

Arantor

Quote from: syrinx75 on February 27, 2011, 02:36:12 AM
Hello flapjack,

Is it a solution to add this code automatically in all the html page?
<HTML><HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD><BODY>
</BODY>
</HTML>


I'm looking how to to do that with SMR 1.1.13. How can I do?

Thank you for help.

I explained how to do this in your other thread.


Arantor

http://www.simplemachines.org/community/index.php?topic=424073.msg2969982#msg2969982

Though there's no reason why you couldn't just add it to $context['html_headers'], I just took the shortcut of adding it directly to the theme.

TW1ST3D

Hi ! Great mod !  but it seems to be breaking my Ajax.  When the mod is enabled from the admin center, neither my members or myself can insert quotes nor preview the post.  I am running 2.0RC5 with multiple mods and have tested thoroughly to make sure that it is this mod that is doing it. any ideas?
Running 2.0 Gold.......SMF Rocks!!

Arantor

So what did you add to the header using this mod?

TW1ST3D

A marquee scroller.


<script language="JavaScript1.2">

//Specify the marquee's width (in pixels)
var marqueewidth="1400px"
//Specify the marquee's height
var marqueeheight="18px"
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=2
//configure background color:
var marqueebgcolor="red"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=0

//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='<nobr><font face="Arial" font color="white" font size="4">REMEMBER TO SET YOUR CLOCKS AHEAD THIS SATURDAY NIGHT.....................SPRING FORWARD.~GALXClub.com</font></nobr>'


////DO NOT EDIT BELOW THIS LINE////////////
marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>')
var actualwidth=''
var cross_marquee, ns_marquee

function populate(){
if (iedom){
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
cross_marquee.innerHTML=marqueecontent
actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
}
else if (document.layers){
ns_marquee=document.ns_marquee.document.ns_marquee2
ns_marquee.left=parseInt(marqueewidth)+8
ns_marquee.document.write(marqueecontent)
ns_marquee.document.close()
actualwidth=ns_marquee.document.width
}
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate

function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"

}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else
ns_marquee.left=parseInt(marqueewidth)+8
}
}

if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
write('<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}
</script>
<br>
<br>
Running 2.0 Gold.......SMF Rocks!!

Arantor

Small wonder it's broken, virtually every line of JS there is invalid. I don't have time to sit and rewrite it now though, but trust me, it's invalid JS which is why you have issues. (For example, lines are generally supposed to have ; at the end of them... and write on its own doesn't normally do anything, needs to be document.write)

And wow, that's really, really old code. It's basically written for browsers that were common a decade ago.

TW1ST3D

Yeah......it is old, I found it in some archives somewhere......I can't even remember where.  I'll look for something more up to date. Thanks for the advice.
Running 2.0 Gold.......SMF Rocks!!

flapjack

Quote from: TW1ST3D on March 09, 2011, 01:39:17 PM
Hi ! Great mod !  but it seems to be breaking my Ajax.  When the mod is enabled from the admin center, neither my members or myself can insert quotes nor preview the post.  I am running 2.0RC5 with multiple mods and have tested thoroughly to make sure that it is this mod that is doing it. any ideas?
it's impossible for this mod to break anything. all it does is inserting the text you put into the textbox into the header. no other stuff is being added or removed. so as long es the code you're using works, it's impossible to break anything

I cannot say whether your JS is correct or not, but I'm using it extensively (and looking at the stats it seems it became very popular amongst other people too, which is great) and it never breaks

Arantor

And that's the point: the JS itself being added is broken, so it breaks other things in consequence.

TW1ST3D

Quote from: flapjack on March 09, 2011, 02:24:12 PM
Quote from: TW1ST3D on March 09, 2011, 01:39:17 PM
Hi ! Great mod !  but it seems to be breaking my Ajax.  When the mod is enabled from the admin center, neither my members or myself can insert quotes nor preview the post.  I am running 2.0RC5 with multiple mods and have tested thoroughly to make sure that it is this mod that is doing it. any ideas?
it's impossible for this mod to break anything. all it does is inserting the text you put into the textbox into the header. no other stuff is being added or removed. so as long es the code you're using works, it's impossible to break anything

I cannot say whether your JS is correct or not, but I'm using it extensively (and looking at the stats it seems it became very popular amongst other people too, which is great) and it never breaks

Take it easy........I wasn't bashing the mod, in fact I love it......But something was breaking the Ajax so that is why I came here to ask about it. Arantor took a look and discovered that I was running some old .js and that in fact was breaking the Ajax. Problem solved. I'll try to find some other more up to date .js to use. and Thanks for creating this mod!! it is excellent!!
Running 2.0 Gold.......SMF Rocks!!

flapjack

didn't want to sound harsh or anything, just wanted to emphasize how the mod works and why it's impossible for the mod to break anything :)

ljunatic

I had the same problem with broken preview and quote as well as forum stats problems. When I reloaded my forum all was well until I installed this mod. I was checking these problems after installing each mod. I was only using a simple graphic in the header. When I removed the mod, the quoting and preview issues went away.

I would love to use it again, but my limited experience with coding won't allow it, and I am through working in this. I have already been working many hours trying to fix these problems and I need a break.

Arantor

This mod isn't for adding graphics in the header.

Advertisement: