Quick Help on a custom block

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Quick Help on a custom block
alexcroox
CZ Newbie
alexcroox has been a member for over 18 year's 18 Year Member
Gender: Male
Status: Offline
Joined: Dec 20, 2005
0.00 posts per day
Posts: 17
Points: 570
   
Hi i need a simple solution to create a working phpnuke block since ive tried googling for solutions and following guids but it does seem to work

here is the code i wish to work in a block

<?php
/*
This script displays the events from today
this script is a modified version of list.php from Nick77. Thanks for the original!
ask hamlet in the forum at http://ikemcg.com/scripts/forum/ if there are any questions
*/

require("config.php");
require("lang/lang." . LANGUAGE_CODE . ".php");

$id = $HTTP_GET_VARS['id'];

mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

$sql = "SELECT id, y, m, d, title, text, TIME_FORMAT(start_time, '%k:%i') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%k:%i') AS etime, " . DB_TABLE_PREFIX . "users.uid, fname, lname ";
$sql .= "FROM " . DB_TABLE_PREFIX . "mssgs ";
$sql .= "LEFT JOIN " . DB_TABLE_PREFIX . "users ";
$sql .= "ON (" . DB_TABLE_PREFIX . "mssgs.uid = " . DB_TABLE_PREFIX . "users.uid) ";
$sql .= "WHERE text IS NOT NULL AND (y*10000+m*100+d) = ";
$sql .= "(YEAR(NOW())*10000+MONTH(NOW())*100+DAYOFMONTH(NOW())) ";
$sql .= "ORDER BY y, m, d, start_time";
$result = mysql_query($sql) or die(mysql_error());


echo "
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
   <html>
   <head>
            <title>Your Title goes here</title>
            <link rel="stylesheet" type="text/css" href="css/default.css">
   </head>
   <body>
   ";

$day = date("j");
$month = date("n");
$year = date("Y") ;

$num_rows = mysql_num_rows($result);

if ($myrow = mysql_fetch_array($result)) {

do {

   $wday =  date ("w", mktime(0,0,0,$myrow['m'],$myrow['d'],$myrow['y']));
   $title = stripslashes($myrow["title"]);
   $body = stripslashes(str_replace("n", "<br />", $myrow["text"]));

   if ($myrow["stime"] == "55:55") {
      $timestr = "";
   }
   elseif ($myrow["stime"] == $myrow["etime"]) {
      $timestr = $myrow["stime"] . " o'clock";
   } else {
      $timestr = $myrow["stime"] . "-" . $myrow["etime"] . " o'clock";
   }

echo "
   <span class="">
   event: $title<br>
   time: $timestr<br>
   details: $body
   </span>
   <hr width="200px" align="left">
   ";

  } while ($myrow = mysql_fetch_array($result));

} else {

   echo "Sorry, there are no events today!";

}
?>


what do i need to add for this to work as a block?


Back to top Reply with quote
#2   re: Quick Help on a custom block
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
for starters! blocks use

$content = "line 1";
$content  .= "line2";


Instead of
echo "line1";



Back to top Reply with quote
#3   re: Quick Help on a custom block
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
Not sure where you snagged that code at. It would take some minutes to convert it for nuke.



Back to top Reply with quote
#4   re: Quick Help on a custom block
alexcroox
CZ Newbie
alexcroox has been a member for over 18 year's 18 Year Member
Gender: Male
Status: Offline
Joined: Dec 20, 2005
0.00 posts per day
Posts: 17
Points: 570
   
i replaced all the echo's with content = and then content .= from then on,

and inserted the needed block header

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


require("config.php");
require("lang/lang." . LANGUAGE_CODE . ".php");

$id = $HTTP_GET_VARS['id'];

mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());

$sql = "SELECT id, y, m, d, title, text, TIME_FORMAT(start_time, '%k:%i') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%k:%i') AS etime, " . DB_TABLE_PREFIX . "users.uid, fname, lname ";
$sql .= "FROM " . DB_TABLE_PREFIX . "mssgs ";
$sql .= "LEFT JOIN " . DB_TABLE_PREFIX . "users ";
$sql .= "ON (" . DB_TABLE_PREFIX . "mssgs.uid = " . DB_TABLE_PREFIX . "users.uid) ";
$sql .= "WHERE text IS NOT NULL AND (y*10000+m*100+d) = ";
$sql .= "(YEAR(NOW())*10000+MONTH(NOW())*100+DAYOFMONTH(NOW())) ";
$sql .= "ORDER BY y, m, d, start_time";
$result = mysql_query($sql) or die(mysql_error());


$content = "]-09
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
   <html>
   <head>
            <title>Your Title goes here</title>
            <link rel="stylesheet" type="text/css" href="css/default.css">
   </head>
   <body>
   ";

$day = date("j");
$month = date("n");
$year = date("Y") ;

$num_rows = mysql_num_rows($result);

if ($myrow = mysql_fetch_array($result)) {

do {

   $wday =  date ("w", mktime(0,0,0,$myrow['m'],$myrow['d'],$myrow['y']));
   $title = stripslashes($myrow["title"]);
   $body = stripslashes(str_replace("n", "<br />", $myrow["text"]));

   if ($myrow["stime"] == "55:55") {
      $timestr = "";
   }
   elseif ($myrow["stime"] == $myrow["etime"]) {
      $timestr = $myrow["stime"] . " o'clock";
   } else {
      $timestr = $myrow["stime"] . "-" . $myrow["etime"] . " o'clock";
   }

$content .= "
   <span class="">
   event: $title<br>
   time: $timestr<br>
   details: $body
   </span>
   <hr width="200px" align="left">
   ";

  } while ($myrow = mysql_fetch_array($result));

} else {

   $content .= "Sorry, there are no events today!";

}


?>


but it still doesnt show the block.

thankyou for your pointers so far


Back to top Reply with quote
#5   re: Quick Help on a custom block
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
What exactly is this a part of? It doesn't consist with any module or nuke database tables.

I really need to know what it is you want to accomplish.



Back to top Reply with quote
#6   re: Quick Help on a custom block
alexcroox
CZ Newbie
alexcroox has been a member for over 18 year's 18 Year Member
Gender: Male
Status: Offline
Joined: Dec 20, 2005
0.00 posts per day
Posts: 17
Points: 570
   
well basicaly its for a calendar module (not made by myself) and this code outputs what events have been inputed on the calendar for that day. So it shows on the home page as a quick summary of the days events. If the user wanted more info then obv they would go into the actual calendar module page.



Back to top Reply with quote
#7   re: Quick Help on a custom block
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
Yeah, I had the same issue. So I kinda custo'd my block for my calendar module.
You need to find a nuke calendar module. Then design the block around your site's spefications.

Lets start there.



Back to top Reply with quote
#8   re: Quick Help on a custom block
alexcroox
CZ Newbie
alexcroox has been a member for over 18 year's 18 Year Member
Gender: Male
Status: Offline
Joined: Dec 20, 2005
0.00 posts per day
Posts: 17
Points: 570
   
ok basicaly this is all that code generates
[ Register or login to view links on this board. ]

so are you sure there isnt a few simple lines that can just put these few lines of text into a box for the main page? (ie a block)



Back to top Reply with quote
#9   Re: re: Quick Help on a custom block
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 


Originally posted by alexcroox @ Fri Oct 06, 2006 9:15 am:

ok basicaly this is all that code generates
[ Register or login to view links on this board. ]

so are you sure there isnt a few simple lines that can just put these few lines of text into a box for the main page? (ie a block)


I am not saying it can not be done, but no its not simple.



Back to top Reply with quote
#10   re: Quick Help on a custom block
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
I took a few minutes and cleaned up your code for nuke. Try this and let me know if it works.

good luck! icon_smile.gif

<?php

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

//require("config.php");
//require("lang/lang." . LANGUAGE_CODE . ".php");

//$id = $HTTP_GET_VARS['id'];
global $db;

$sql = "SELECT id, y, m, d, title, text, TIME_FORMAT(start_time, '%k:%i') AS stime, ";
$sql .= "TIME_FORMAT(end_time, '%k:%i') AS etime, " . DB_TABLE_PREFIX . "users.uid, fname, lname ";
$sql .= "FROM " . DB_TABLE_PREFIX . "mssgs ";
$sql .= "LEFT JOIN " . DB_TABLE_PREFIX . "users ";
$sql .= "ON (" . DB_TABLE_PREFIX . "mssgs.uid = " . DB_TABLE_PREFIX . "users.uid) ";
$sql .= "WHERE text <> '' AND ((y*10000)+(m*100+d)) = ";
$sql .= "(YEAR(NOW())*10000+MONTH(NOW())*100+DAYOFMONTH(NOW())) ";
$sql .= "ORDER BY y, m, d, start_time";
$result = $db->sql_query($sql);

$day = date("j");
$month = date("n");
$year = date("Y");

$num_rows = $db->sql_numrows($result);
If ($num_rows > 0){
For ($x=0;$x<$num_rows;$x++){
   $myrow = $db->sql_fetchrow($result);
   $wday = date ("w", mktime(0,0,0,$myrow['m'],$myrow['d'],$myrow['y']));
    $title = stripslashes($myrow["title"]);
    $body = stripslashes(str_replace("n", "<br />", $myrow["text"]));

   if ($myrow["stime"] == "55:55") {
      $timestr = "";
     }
     elseif ($myrow["stime"] == $myrow["etime"]) {
       $timestr = $myrow["stime"] . " o'clock";
       } else {
         $timestr = $myrow["stime"] . "-" . $myrow["etime"] . " o'clock";
   }

   $content .= "<span class="">event: $title<br>
               time: $timestr<br>
            details: $body</span>
            <hr width="200px" align="left">";
}
} else {
  $content .= "Sorry, there are no events today!";
}
?>




_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
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 cannot attach files in this forum
You cannot download files in this forum