What am I missing here? Do I need to add anything else to the block? Just want to show the weather for my area in a block. Don't want to call on any module or anything else.
Whoa...got a chick avatar? What's up with that?
Thanks in advance
Raven General
Joined: Mar 22, 2003
Posts: 5233
Location: USA
Posted:
Sat May 31, 2003 8:51 pm
You have a space after the _HTMLCODE_. That is expressedly forbidden and I emphasize that in my posts. Remove the space and only have a carriage return. Then it should work
Although the code didn't work just by going to the add a new block section in the admin and pasting it there, it did work with me opening up the sample block and adding the code there.
I just uploaded that block to my server changing the name to "block_localweather.php" and Shazam! it works perfectly.
Thanks again.
Now, how about a real challange. Care to try with multiple scripts? Look at the next post.
Gotta get rid of this chick avatar.....
Dauthus Sergeant
Joined: Feb 12, 2003
Posts: 82
Location: USA
Posted:
Sat May 31, 2003 9:15 pm
Think I can eventually get this in a block or maybe in the content section?
Code:
<!-- Start Of Moreover.com News Javascript Code -->
<SCRIPT LANGUAGE="Javascript">
<!--
// the array global_article is used to allow multiple categories
var global_article = new Array();
var global_article_counter = 0;
var article = null;
var early_exit = true;
var moreover_text = 0;
function load_wizard()
{
var newwin = window.open("","clone","resizable,scrollbars");
document.forms.moreover_clone.submit();
return true;
}
// -->
global_article[global_article_counter].url += "' TARGET='_blank";
global_article[global_article_counter].document_url += "' TARGET='_blank";
global_article_counter++;
}
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript">
<!--
if (global_article.length == 0)
{
if (early_exit)
{
document.write("<CENTER>Please reload this page to view the headlines</CENTER>");
}
else
{
document.write("<CENTER>Sorry, no articles matched your search criteria</CENTER>");
early_exit = true;
}
}
// -->
</SCRIPT>
<table cellpadding=4 cellspacing=0 border=0 width='400'><tr bgcolor='#FFFFFF'><td>
<a href='http://www.moreover.com/cgi-local/page?o=portal&c=Top%20stories&o=js' target='_blank' class='morehlt'>Top stories</a><br>&<br>
<SCRIPT LANGUAGE="Javascript">
<!--
if (!early_exit)
{
var wizard_brand = "moreover";
var webfeed_heading = "Top stories";
var width = "400";
var numberofarticles = global_article.length;
var cluster_border = "0";
var time_display = "Yes";
var cell_spacing = "0";
var cell_padding = "1";
var time = new Array(global_article.length);
// Start loop for articles
for (var counter=0; counter < numberofarticles; counter++)
{
// Print out the headline
document.write("<a href='"+global_article[counter].url+"' class='morehl'>");
document.write(global_article[counter].headline_text+"...</a><br>");
// Print out the source
if ((counter != (global_article.length - 1)) || moreover_text != 1)
{
// Print out reg/sub/prem if appropriate
if (global_article[counter].access_status == "sub" || global_article[counter].access_status == "reg" || global_article[counter].access_status == "prem")
{
document.write("<span class='moreti'>&</span><A HREF='"+global_article[counter].access_registration+"' class='moresrc'>");
document.write(global_article[counter].access_status+"</A>");
}
// Print out the harvest time
if (time_display == "Yes")
{
// Make a new date object
time[counter] = new Date(global_article[counter].harvest_time);
time[counter].setHours(time[counter].getHours() - (time[counter].getTimezoneOffset() / 60 ));
document.write("<span class='moreti'> &"+time[counter].toString()+"<br>&<br></span>");
}
else
{
document.write("<br>&<br>");
}
document.write("</FORM>");
// End of clone button code //
// ************************************************************************************
// This code is subject to the copyright and warranty restrictions detailed at
// http://www.moreover.com/wizard_copyright.html
// Copyright 2000 Moreover.com Inc. All rights reserved.
// *************************************************************************************
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript" SRC="http://p.moreover.com/dr/wizard/wizard_text.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
setTimeout("window.location.reload(true)", 900*1000); // refresh time in ms
</SCRIPT>
</td></tr></table>
<!-- End Of Moreover.com News Javascript Code -->
Would be nice in a block, but this is way, way out of my league. It pastes nice into html, and reads fine, just kicks me back to the index when I try and use it in Nuke. You would have my eternal thanks for some help on this one.
Raven General
Joined: Mar 22, 2003
Posts: 5233
Location: USA
Posted:
Sat May 31, 2003 9:21 pm
Dauthus wrote:
Thank you Raven!
Although the code didn't work just by going to the add a new block section in the admin and pasting it there, it did work with me opening up the sample block and adding the code there.
I just uploaded that block to my server changing the name to "block_localweather.php" and Shazam! it works perfectly.
Thanks again.
Now, how about a real challange. Care to try with multiple scripts? Look at the next post.
Gotta get rid of this chick avatar.....
That's because by default a block expects HTML. To execute that code in the Admin Block, you have to wrap it in <? ?> tags and then add an echo $content; statement.
<SCRIPT LANGUAGE="Javascript">
<!--
// the array global_article is used to allow multiple categories
var global_article = new Array();
var global_article_counter = 0;
var article = null;
var early_exit = true;
var moreover_text = 0;
function load_wizard()
{
var newwin = window.open("","clone","resizable,scrollbars");
document.forms.moreover_clone.submit();
return true;
}
// -->
global_article[global_article_counter].url += "' TARGET='_blank";
global_article[global_article_counter].document_url += "' TARGET='_blank";
global_article_counter++;
}
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript">
<!--
if (global_article.length == 0)
{
if (early_exit)
{
document.write("<CENTER>Please reload this page to view the headlines</CENTER>");
}
else
{
document.write("<CENTER>Sorry, no articles matched your search criteria</CENTER>");
early_exit = true;
}
}
// -->
</SCRIPT>
<table cellpadding=4 cellspacing=0 border=0 width='400'><tr bgcolor='#FFFFFF'><td>
<a href='http://www.moreover.com/cgi-local/page?o=portal&c=Top%20stories&o=js' target='_blank' class='morehlt'>Top stories</a><br>&<br>
<SCRIPT LANGUAGE="Javascript">
<!--
if (!early_exit)
{
var wizard_brand = "moreover";
var webfeed_heading = "Top stories";
var width = "400";
var numberofarticles = global_article.length;
var cluster_border = "0";
var time_display = "Yes";
var cell_spacing = "0";
var cell_padding = "1";
var time = new Array(global_article.length);
// Start loop for articles
for (var counter=0; counter < numberofarticles; counter++)
{
// Print out the headline
document.write("<a href='"+global_article[counter].url+"' class='morehl'>");
document.write(global_article[counter].headline_text+"...</a><br>");
// Print out the source
if ((counter != (global_article.length - 1)) || moreover_text != 1)
{
// Print out reg/sub/prem if appropriate
if (global_article[counter].access_status == "sub" || global_article[counter].access_status == "reg" || global_article[counter].access_status == "prem")
{
document.write("<span class='moreti'>&</span><A HREF='"+global_article[counter].access_registration+"' class='moresrc'>");
document.write(global_article[counter].access_status+"</A>");
}
// Print out the harvest time
if (time_display == "Yes")
{
// Make a new date object
time[counter] = new Date(global_article[counter].harvest_time);
time[counter].setHours(time[counter].getHours() - (time[counter].getTimezoneOffset() / 60 ));
document.write("<span class='moreti'> &"+time[counter].toString()+"<br>&<br></span>");
}
else
{
document.write("<br>&<br>");
}
document.write("</FORM>");
// End of clone button code //
// ************************************************************************************
// This code is subject to the copyright and warranty restrictions detailed at
// http://www.moreover.com/wizard_copyright.html
// Copyright 2000 Moreover.com Inc. All rights reserved.
// *************************************************************************************
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="Javascript" SRC="http://p.moreover.com/dr/wizard/wizard_text.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
setTimeout("window.location.reload(true)", 900*1000); // refresh time in ms
</SCRIPT>
</td></tr></table>
<!-- End Of Moreover.com News Javascript Code -->
_HTMLCODE_;
?>
Thank you, thank you, thank you. The downloaded file works perfect. I am going to look at it on dreamweaver and see what was wrong.
You are a life safer. Thanks again.
MrPat Nuke Cadet
Joined: Jul 02, 2003
Posts: 3
Posted:
Wed Jul 02, 2003 9:04 am
I'm bumping this post, coz i have a similar problem !
This is the code i'd like to put in a block, but i'm not really use to that .. can somedy look at it, and tell me if there is something wrong (perhaps yes coz it doesn't work). Thanks a lot.
function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}
//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
//STEP 1: Configure the countdown-to date, in the format year, month, day:
setcountdown(2003,7,6)
//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion=" Le Grand Prix de France."
var message_on_occasion="Aujourd'hui, le Grand Prix de France!"
//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='600px'
var countdownheight='50px'
var countdownbgcolor='#FFFFFF'
var opentags='<font size="2" face="Verdana" color="#000000"><b>'
var closetags='</b></font>'
//////////DO NOT EDIT PASS THIS LINE//////////////////
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''
function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}
if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
window.onload=start_countdown
function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//if on day of occasion
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " jours, "+dhour+" heures, "+dmin+" minutes, et "+dsec+" secondes depuis "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " jours, "+dhour+" heures, "+dmin+" minutes, et "+dsec+" secondes avant"+occasion+closetags
}
setTimeout("countdown()",1000)
}
</script>
</div>
Raven General
Joined: Mar 22, 2003
Posts: 5233
Location: USA
Posted:
Wed Jul 02, 2003 11:01 am
As I have posted many times, you cannot add it to a block like this. read the first post in this thread as to how to 'wrap' the code.
Understanding how it works, i wouldn't have post here .. but the fact is, i'm french and i have sometimes a lil problem to understand coz i need to translate to myself to understand.
Having a lil help on how-to do it, would help .. not only refering to another post. Coz i can understand way better, if my example works in the end.
Thanks in advance for taking care of my problem.
Raven General
Joined: Mar 22, 2003
Posts: 5233
Location: USA
Posted:
Wed Jul 02, 2003 11:47 am
<?
$content = <<< _CODE_
/** Place all your code here **/
_CODE_;
?>
Make sure there are no spaces after the _CODE_ tags. Only a carriage return. That is all there is to it.
Thanx a lot Raven ! I know i'm still in the block section.. but if i want to put the same script .. in the middle of a php page already existing !! Is there a way to declare the script ... and ask it, whenever i need it in the same page ??
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