Hi to everyone.
I'm thinking that the following should go in the coding board but since I am a 'newbie' then I will post it here.
I figure the best approach to this is to explain it as fully as possible, it saves doing the back and forth when some information is left out.
Over at Dynamic Drive they have a nice script which opens a centered popup window link to whateve site you choose. At the present I am working on a forum and figured that the popup would be great as a link to a dictionary. At DD they do the usual of showing you what to place in the head section and then what to place in the body.
Now, if it were a regular web page I would have no problem since I've used some scripts from DD and elsewhere to good effect. But being new to the "mysterious" world of PHP I'm having a tricky time and though I've been making some good progress this particular problem simply requiires advice from the more knowledgeable.
The following is what I'm trying to add in the index.template.php of the forum so as to get that popup window. The first one shows where I placed the script right before the end of the head section (blue text). The second shows the link in body; I won't display the adjustments I made to the body link since none of them worked, the one displayed here is the one that works and is in use at the present.
- Head section
.
.
.
// the routine for the info center upshrink
echo '
<script language="JavaScript" type="text/javascript">
var current_header_ic = ', empty($options['collapse_header_ic']) ? 'false' : 'true', ';
function shrinkHeaderIC(mode)
{';
if ($context['user']['is_guest'])
echo '
document.cookie = "upshrinkIC=" + (mode ? 1 : 0);';
else
echo '
smf_setThemeOption("collapse_header_ic", mode ? 1 : 0, null, "', $context['session_id'], '");';
echo '
document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");
document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";
current_header_ic = mode;
}
</script>
<script language="javascript">
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>
2. Link
// Show the [Dictionary] button.
echo ($current_action=='Dictionary' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'dictionary' ? 'current' : '' , '"><a href="http://website.com"', $scripturl, '?action=Dictionary">' , $txt['Dictionary'] , '</a></li>';
Now, what DD tells one to do is to modify the <a href="http;//......etc. part above with the following (changed to dictionary):
<a href="http://dictionary.com" onclick="NewWindow(this.href,'name','400','400','yes');return false">Dictionary</a>
Again, this would be easy enough with a regular page since I've used something similar before. But my attempts to modify the link as DD suggests has only yielded the dreaded 'Template Parse Error' page.
I then removed whatever attempts at modification in the link and reverted to the working one yet left the script in the head section figuring that since I did no modification whatsoever on it then it would be okay. Well, it wasn't. After uploading the original link code it was still TPE. In the end I had to remove both and TPE was gone, everything reappeared as before and displaying properly.
If someone can give me handle on this it will be appreciated. No doubt this will be a breeze when I learn more PHP but for now it's a bit on the windy side. :-)
Dan