Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
mrix
Client



Joined: Dec 04, 2004
Posts: 757

PostPosted: Sat Jun 18, 2005 7:40 am Reply with quote

Hi all, I have this peice of java script and would like to add it to a block, I have added it to a block as it is and it works but outside of the block which can been seen here if you scroll down the page you will see a dice that shows random numbers etc http://www.horse-racing-league.com , what code do I need to add to get it working inside the block?
many thanks for any help
Cheers
mrix
 
View user's profile Send private message Visit poster's website
Manuel
Regular
Regular



Joined: May 28, 2005
Posts: 90

PostPosted: Sat Jun 18, 2005 8:08 am Reply with quote

you need to put the javascript code in blocks/yourblock.php

at the end of file, before ?> add this:

Code:


$content .= '

PASTE CODE HERE

';

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Jun 18, 2005 8:52 am Reply with quote

http://www.ravenphpscripts.com/postt28.html
 
View user's profile Send private message
mrix







PostPosted: Sat Jun 18, 2005 1:33 pm Reply with quote

Many thanks all is working fin with that extra code
Cheers
mrix
 
mrix







PostPosted: Sun Jun 19, 2005 6:42 am Reply with quote

Hi again, can i change it so only the admin can press the dice button but for all members and visitors to see it on the front page?
would this be complex to do or straight forward?
Thanks for any help
Cheers
mrix I did post the code or try to but the site banned me for some reason?
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sun Jun 19, 2005 8:04 am Reply with quote

the site banned you because you tried to post J avascript. If you change each of your J avascript statements to have a space between one of more letters (like what I did here), it would have posted.

To answer your question, it IS rather straight forward. You make the block visible to all via the nuke admin tool, but within your block, you have to add code to check to see if an admin is logged on. If the admin is the one logged on, then you build the necessary link around the graphic. If the admin is NOT the one logged on, then leave off the link.

Regards,
montego

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
mrix







PostPosted: Sun Jun 19, 2005 8:28 am Reply with quote

I understand the first bit but the second "If the admin is the one logged on, then you build the necessary link around the graphic. If the admin is NOT the one logged on, then leave off the link" is behond me to be honest Sad , is it possible if you good explain the edits in my code below ?
many thanks for your time
Cheers
mrix

this is my code
Code:
<?php


if (eregi("block-Dice.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

$content .= '
scripttagwashere
/*

*/

//preload the three images first
var face0=new Image()
face0.src="d1.gif"
var face1=new Image()
face1.src="d2.gif"
var face2=new Image()
face2.src="d3.gif"
var face3=new Image()
face3.src="d4.gif"
var face4=new Image()
face4.src="d5.gif"
var face5=new Image()
face5.src="d6.gif"
scripttagwashere


<img src="d1.gif" name="mydice">
<form>
<input type="button" value="Throw dice!" onClick="throwdice()">
</form>
scripttagwashere
function throwdice(){
//create a random integer between 0 and 1
var randomdice=Math.round(Math.random()*2)
document.images["mydice"].src=eval("face"+randomdice+".src")
}
scripttagwashere
';

?>
 
montego







PostPosted: Sun Jun 19, 2005 10:22 am Reply with quote

Personally, I do not like the way you have coded the $content variable build, but I don't have time to recode it for you. Here is one suggestion (others here with more experience might suggest a more robust solution):

Code:


if (is_admin($admin)) {
    $content .= "<form>
<input type=\"button\" value=\"Throw dice!\" onClick=\"throwdice()\">
</form>";
}


You need to figure out the proper syntax based on your own preference. you will also need to add the following code after your eregi if statement:

global $admin

the if statement identified above will show the Throw Dice button only if you are logged in as the site's admin (i.e., through admin.php). I don't have time right now to find and give you the code to work for all site admins/authors.

Regards,
montego
 
mrix







PostPosted: Sun Jun 19, 2005 11:49 am Reply with quote

Great montego, I appriciate your time on this to help
Cheers
mrix
 
Manuel







PostPosted: Sun Jun 19, 2005 10:21 pm Reply with quote

cause you have only one definition of $content i suggest to you to replace $content .= with $content =
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot 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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©