You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 232 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Insert Javascript [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
This forum is locked: you cannot post, reply to, or edit topics.  This topic is locked: you cannot edit posts or make replies.printer-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Guest







PostPosted: Wed Jan 21, 2004 12:49 pm Reply with quoteBack to top

I have already searched the forum and didnt find what i needed...this may seem very simple to some but i am not entirely sure what todo and some help would be much appericated.

I want to insert the follow javascript into the <head> however i have no idea where the <head> is since im using php-nuke. The code simply displays messages in the status bar,there are other scripts i would like to add aslo so an explained method would help thx

Code:
<script type="text/javascript">
//Created by Status bar Maker (http://www.bosiljak.hr/sbmaker)
function sb1_makeArray(n){
   this.length = n;
   return this.length;
}

sb1_messages = new sb1_makeArray(3);
sb1_messages[0] = "Welcome";
sb1_messages[1] = "Register as a member and gain many benefits";
sb1_messages[2] = "Don't forget to check the forum out";
sb1_bln = 50;
sb1_rptType = 'infinite';
sb1_rptNbr = 5;
sb1_speed = 100;
sb1_counter=1;
sb1_timer = null;
sb1_last = 1;
sb1_st='';
sb1_currMsg = 0;
function sb1_scrollStatus(){
if (sb1_last > sb1_messages[sb1_currMsg].length){
   if (sb1_st.length == 0){
   sb1_last=1;
      if (sb1_currMsg == sb1_messages.length-1){
         if ((sb1_rptType == 'finite') && (sb1_counter==sb1_rptNbr)){
            clearTimeout(sb1_timer);
            return;
         }
         sb1_counter++;
         sb1_currMsg=0;
      }
   else{
      sb1_currMsg++;
   }
}
else{
   sb1_st=sb1_st.substring(1,sb1_st.length);
}
}
else{
   sb1_st = sb1_messages[sb1_currMsg].substring(0, sb1_last);
   for (var i=0; i<=(sb1_bln+sb1_messages[sb1_currMsg].length-sb1_last); i++)
      sb1_st=" "+sb1_st;
   sb1_last++;
}
window.status = sb1_st;
sb1_timer = setTimeout("sb1_scrollStatus()", sb1_speed);
}
sb1_scrollStatus();
</script>
Find all posts by Anonymous
kingpin03
Corporal
Corporal


Joined: Nov 14, 2003
Posts: 61


PostPosted: Thu Jan 22, 2004 7:25 am Reply with quoteBack to top

the <head> tags can be found in the file header.php

The <body> tags can be found in the theme.php of every theme that you use.
Make sure that when you insert that code you put
?> before and <?php after, so that it doesn't interfere with the PHP code.
So here is how you'd insert your code in the header.php file:
Code:

?>
<script type="text/javascript">
//Created by Status bar Maker (http://www.bosiljak.hr/sbmaker)
function sb1_makeArray(n){
   this.length = n;
   return this.length;
}

sb1_messages = new sb1_makeArray(3);
sb1_messages[0] = "Welcome";
sb1_messages[1] = "Register as a member and gain many benefits";
sb1_messages[2] = "Don't forget to check the forum out";
sb1_bln = 50;
sb1_rptType = 'infinite';
sb1_rptNbr = 5;
sb1_speed = 100;
sb1_counter=1;
sb1_timer = null;
sb1_last = 1;
sb1_st='';
sb1_currMsg = 0;
function sb1_scrollStatus(){
if (sb1_last > sb1_messages[sb1_currMsg].length){
   if (sb1_st.length == 0){
   sb1_last=1;
      if (sb1_currMsg == sb1_messages.length-1){
         if ((sb1_rptType == 'finite') && (sb1_counter==sb1_rptNbr)){
            clearTimeout(sb1_timer);
            return;
         }
         sb1_counter++;
         sb1_currMsg=0;
      }
   else{
      sb1_currMsg++;
   }
}
else{
   sb1_st=sb1_st.substring(1,sb1_st.length);
}
}
else{
   sb1_st = sb1_messages[sb1_currMsg].substring(0, sb1_last);
   for (var i=0; i<=(sb1_bln+sb1_messages[sb1_currMsg].length-sb1_last); i++)
      sb1_st=" "+sb1_st;
   sb1_last++;
}
window.status = sb1_st;
sb1_timer = setTimeout("sb1_scrollStatus()", sb1_speed);
}
sb1_scrollStatus();
</script>
<?php


Also, if you ever want to insert javscript in a block, you'll have to use phpMyAdmin to do that because you can't insert Javascript into a normal block. Not sure why, but that's how it is.
You basically just create a block and then go to your mySQL manager (phpMyAdmin for example) and insert the Javascript there. Just in case you ever need it.[/code]

_________________
My PHPNukeMods:
pvPhortunes 1.0

Sites:
PV-D
HTK
Find all posts by kingpin03View user's profileSend private message
Guest







PostPosted: Thu Jan 22, 2004 9:47 am Reply with quoteBack to top

Thx for the help much appericated....so could i just stick this into the header.pjhp?? will that do the job, becasue if i search within header.php i find no <head> tag
Find all posts by Anonymous
kingpin03
Corporal
Corporal


Joined: Nov 14, 2003
Posts: 61


PostPosted: Fri Jan 23, 2004 5:24 am Reply with quoteBack to top

In header.php somewhere near line 25 you will see the following:
Code:

##################################################
# Include some common header for HTML generation #
##################################################

$header = 1;

function head() {
    global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle;
    $ThemeSel = get_theme();
    include("themes/$ThemeSel/theme.php");
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
    echo "<html>\n";
    echo "<head>\n";
    echo "<title>$sitename $pagetitle</title>\n";

After that bit, exactly beneath it, insert the code the way I said earlier.
Like this:
Code:

##################################################
# Include some common header for HTML generation #
##################################################

$header = 1;

function head() {
    global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle;
    $ThemeSel = get_theme();
    include("themes/$ThemeSel/theme.php");
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
    echo "<html>\n";
    echo "<head>\n";
    echo "<title>$sitename $pagetitle</title>\n";
?>
<script type="text/javascript">
//Created by Status bar Maker (http://www.bosiljak.hr/sbmaker)
function sb1_makeArray(n){
   this.length = n;
   return this.length;
}

sb1_messages = new sb1_makeArray(3);
sb1_messages[0] = "Welcome";
sb1_messages[1] = "Register as a member and gain many benefits";
sb1_messages[2] = "Don't forget to check the forum out";
sb1_bln = 50;
sb1_rptType = 'infinite';
sb1_rptNbr = 5;
sb1_speed = 100;
sb1_counter=1;
sb1_timer = null;
sb1_last = 1;
sb1_st='';
sb1_currMsg = 0;
function sb1_scrollStatus(){
if (sb1_last > sb1_messages[sb1_currMsg].length){
   if (sb1_st.length == 0){
   sb1_last=1;
      if (sb1_currMsg == sb1_messages.length-1){
         if ((sb1_rptType == 'finite') && (sb1_counter==sb1_rptNbr)){
            clearTimeout(sb1_timer);
            return;
         }
         sb1_counter++;
         sb1_currMsg=0;
      }
   else{
      sb1_currMsg++;
   }
}
else{
   sb1_st=sb1_st.substring(1,sb1_st.length);
}
}
else{
   sb1_st = sb1_messages[sb1_currMsg].substring(0, sb1_last);
   for (var i=0; i<=(sb1_bln+sb1_messages[sb1_currMsg].length-sb1_last); i++)
      sb1_st=" "+sb1_st;
   sb1_last++;
}
window.status = sb1_st;
sb1_timer = setTimeout("sb1_scrollStatus()", sb1_speed);
}
sb1_scrollStatus();
</script>
<?php


_________________
My PHPNukeMods:
pvPhortunes 1.0

Sites:
PV-D
HTK
Find all posts by kingpin03View user's profileSend private message
dezina
Support Mod
Support Mod


Joined: Jun 09, 2003
Posts: 1713

Location: England

PostPosted: Fri Jan 23, 2004 5:53 am Reply with quoteBack to top

Java Script in header should be entered into
/includes/my_header.php Wink

_________________
Image
Backup files BEFORE altering
Use PHPNuke 7.6 with patches!!
No private messages please, POST in forums.
Find all posts by dezinaView user's profileSend private messageVisit poster's website
Guest







PostPosted: Fri Jan 23, 2004 10:24 am Reply with quoteBack to top

Thx all btw what is the diffrence between adding it into header.php and my_header.php?? will it not show up on certain pages if i only put it in header.php??

Last question and the answer may be the above but not sure, but is it possible to refer to a .php or .txt file for the javascript rather than inserting the code itslef into header.php, since i may need to edit the code on a regualr basis and don't want to affect the header.php file

Thx
Find all posts by Anonymous
gschoper
Captain
Captain


Joined: Sep 16, 2003
Posts: 380


PostPosted: Fri Jan 23, 2004 10:52 am Reply with quoteBack to top

Anonymous wrote:
Thx all btw what is the diffrence between adding it into header.php and my_header.php?? will it not show up on certain pages if i only put it in header.php??

Last question and the answer may be the above but not sure, but is it possible to refer to a .php or .txt file for the javascript rather than inserting the code itslef into header.php, since i may need to edit the code on a regualr basis and don't want to affect the header.php file

Thx


my_header.php is there specifically for these types of customizations so you don't have to mess with header.php.

To answer you second question, that is the recommended way of doing it. Create a file called whatever.inc in the root of your PHP-Nuke install and place your code in it. Then place the following line into my_header.php:

Code:

include("whatever.inc");


HTH,

gschoper

_________________
Image
http://nuke.schoper.net/
Find all posts by gschoperView user's profileSend private messageSend e-mailVisit poster's website
Guest







PostPosted: Fri Jan 23, 2004 2:03 pm Reply with quoteBack to top

Thx a lot, can the following be used if i do not want to store it in the root directory?

include (scripts/whatever.inc)

Is there any particular reason for having hte file extension as .inc
Find all posts by Anonymous
Guest







PostPosted: Fri Jan 23, 2004 2:05 pm Reply with quoteBack to top

Can this method be used for all types of coding?, html/php/javascript etc
Find all posts by Anonymous
gschoper
Captain
Captain


Joined: Sep 16, 2003
Posts: 380


PostPosted: Fri Jan 23, 2004 2:18 pm Reply with quoteBack to top

Anonymous wrote:
Thx a lot, can the following be used if i do not want to store it in the root directory?

include (scripts/whatever.inc)

Yes.

Quote:

Is there any particular reason for having hte file extension as .inc

Just so you know it's an include file. You can use anything you want.

Quote:

Can this method be used for all types of coding?, html/php/javascript etc

Yes.

HTH,

gschoper

_________________
Image
http://nuke.schoper.net/
Find all posts by gschoperView user's profileSend private messageSend e-mailVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Fri Jan 23, 2004 2:18 pm Reply with quoteBack to top

The simplest and best way to enter javascript into any php script, be it a nuke block, module, or whatever, is to use the WHEREDOC (sometimes called HEREDOC) syntax. See this post http://nukecops.com/postt2548.html

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
gschoper
Captain
Captain


Joined: Sep 16, 2003
Posts: 380


PostPosted: Fri Jan 23, 2004 2:27 pm Reply with quoteBack to top

Raven wrote:
The simplest and best way to enter javascript into any php script, be it a nuke block, module, or whatever, is to use the WHEREDOC (sometimes called HEREDOC) syntax. See this post http://nukecops.com/postt2548.html


Agreed. I tend to use include() because I'm displaying the same code in multiple locations and it allows a central point for editing and it also allows me to keep all of my non-nuke code in the same place.

gschoper

_________________
Image
http://nuke.schoper.net/
Find all posts by gschoperView user's profileSend private messageSend e-mailVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Fri Jan 23, 2004 2:54 pm Reply with quoteBack to top

gschoper wrote:
Raven wrote:
The simplest and best way to enter javascript into any php script, be it a nuke block, module, or whatever, is to use the WHEREDOC (sometimes called HEREDOC) syntax. See this post http://nukecops.com/postt2548.html


Agreed. I tend to use include() because I'm displaying the same code in multiple locations and it allows a central point for editing and it also allows me to keep all of my non-nuke code in the same place.

gschoper
That makes sense for those situations where you have reusable objects across applications/scripts.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
Display posts from previous:      
This forum is locked: you cannot post, reply to, or edit topics.  This topic is locked: you cannot edit posts or make replies.printer-friendly view
View previous topic Log in to check your private messages View next topic
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.044 Seconds - 253 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::