PDA

View Full Version : Calander on non-VB pages


Curll
04-30-2004, 08:02 PM
I'm looking for a hack or a PHP script that can put today's events from the calander on a non-vB page, namely my site's main page. Maybe something cute in a Calander square looking dealy.

Thanks

Pseudomizer
05-01-2004, 10:54 PM
I'm looking for a hack or a PHP script that can put today's events from the calander on a non-vB page, namely my site's main page. Maybe something cute in a Calander square looking dealy.

Thanks

Hi Curl,

please use the following code to get the last 5 events in an array:


$events = $DB_site->query("select * from event order by dateline DESC limit 5");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{

$serveroffset = date('Z', TIMENOW) / 3600;

$fromdate = getdate(TIMENOW + (-12 - $serveroffset) * 3600);
$new_date = date('d-m-Y', TIMENOW + (-12 - $serveroffset) * 3600 );

echo $new_date," ";
// echo $ev['userid']," ";
// echo $ev['dateline']," ";
echo $ev['title'],"<BR>";
}
}


Cheers,

Curll
05-02-2004, 02:09 PM
Yay, thanks. That's a good start.

Pseudomizer
05-02-2004, 02:52 PM
Yay, thanks. That's a good start.

Hi Curl,

sorry but i just found one mistake. The dateline will never change in my previous code. Please use the following code:


$events = $DB_site->query("select * from event order by dateline DESC limit 5");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$new_date = vbdate('d.m.Y', $ev['dateline'], false, false);
$news .= "<B>".$new_date."</B><BR>";
$news .= $ev['title']."<BR>";

}
}

P.Jackson
05-02-2004, 03:40 PM
what would be the code to get total threads and how many users online?

Pseudomizer
05-02-2004, 04:07 PM
what would be the code to get total threads and how many users online?

Users online:


$onlineusers = $DB_site->query("
## GET ONLINE USERS ##
SELECT user.username, (user.options & $_USEROPTIONS[invisible]) AS invisible,
user.usergroupid, session.userid, session.lastactivity,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM ".TABLE_PREFIX."session AS session
LEFT JOIN ".TABLE_PREFIX."user AS user ON (user.userid = session.userid)
WHERE session.lastactivity > $online[datecut]
ORDER BY ".iif($permissions['genericpermissions'] & CANSEEHIDDEN, 'invisible ASC, ')."username ASC");


Total Threads:


$totalthreads = $DB_site->query("Select count(threadid) from thread where visible = '1' );


Cheers,

P.Jackson
05-02-2004, 04:29 PM
didnt work :( got parse errors

Pseudomizer
05-02-2004, 04:42 PM
didnt work :( got parse errors

What didn't work ? What kind of errors do you get ? Sorry but without any information i will not be able to help you at all.

Cheers,

Curll
05-02-2004, 05:23 PM
Odd, with the new code, no events are showing.

Pseudomizer
05-02-2004, 05:26 PM
Odd, with the new code, no events are showing.

I bet you did not write :tired:


echo news;


Cheers,

Curll
05-02-2004, 05:34 PM
echo $news; you mean? :p

Now, anyway I could make those link to the expanded info on the Calander pages? :)

Pseudomizer
05-02-2004, 07:23 PM
echo $news; you mean? :p

Now, anyway I could make those link to the expanded info on the Calander pages? :)

Sure. Link to the calendarid and that's it.

Cheers,

Curll
05-02-2004, 07:44 PM
That was a wee bit vague...or very vague.

echo "<a href=\"calendar.php?$calendarid\">$news</a>";

Obviously isn't going to work.

So, exactly how should I link to the Calendarid?

Pseudomizer
05-02-2004, 07:56 PM
Try this one:


$events = $DB_site->query("select * from event order by dateline DESC limit 5");

if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$news="";
$new_date = vbdate('Y.m.d', $ev['dateline'], false, false);
$news .= "<B>".$new_date."</B><BR>";
$news .= $ev['title']."<BR>";

echo "<A HREF=\"calendar.php?do=getinfo&e=$ev[eventid]&day=$new_date&c=1\">$news</A>";

}
}


Cheers,

Richardg
05-02-2004, 08:15 PM
Hey Pseudomizer..maybe you can help me!

I'm trying to add events from an external calendar.

I've inserted rows with the start date in the dateline_from column & the end date in dateline_to column. I've converted my dates & times using the UNIX_TIMSTAMP
I'm not sure what goes in the dateline or UTC columns
I'm running into trouble with timezone offsets (!)...which may be something to do with the dateline & UTC columns...
I am in BST timezone (British Summer Time).
The event I inserted from my external calendar shows up in he vBulletin calendar but it says it was posted for GMT.
What I want to do is to insert events which always show up correctly for my local time (GTM/BST) even if a) the event spans the point at which local time changes from BST to GMT and b) I insert now (BST) an event which will take place when daylight saving ends and we change to GMT.
cheers

Pseudomizer
05-02-2004, 08:25 PM
Hey Pseudomizer..maybe you can help me!

I'm trying to add events from an external calendar.

I've inserted rows with the start date in the dateline_from column & the end date in dateline_to column. I've converted my dates & times using the UNIX_TIMSTAMP
I'm not sure what goes in the dateline or UTC columns
I'm running into trouble with timezone offsets (!)...which may be something to do with the dateline & UTC columns...
I am in BST timezone (British Summer Time).
The event I inserted from my external calendar shows up in he vBulletin calendar but it says it was posted for GMT.
What I want to do is to insert events which always show up correctly for my local time (GTM/BST) even if a) the event spans the point at which local time changes from BST to GMT and b) I insert now (BST) an event which will take place when daylight saving ends and we change to GMT.
cheers

Hi Richard,

i have never done such a thing before but i can give you some guidance in which direction you should look to find the error. When you post something or you create a thread in all php files they are using the same function. Please have a closer look into this section:


$serveroffset = date('Z', TIMENOW) / 3600;

$fromdate = getdate(TIMENOW + (-12 - $serveroffset) * 3600);
$new_date = date('d-m-Y', TIMENOW + (-12 - $serveroffset) * 3600 );


In addition i would suggest that you look into the calendar_functions.php in your /includes directory.

Hope this helps.

Cheers,

Curll
05-02-2004, 09:36 PM
Hmm, I fooled around with it to get it to work, or at least link correctly (for my site and my settings.)

echo "<hr><b><a href=\"http://www.xblgamers.com/forums/calendar.php?\">Latest Events</a> . . .</b><b><p>";




$events = $DB_site->query("select * from event order by dateline DESC limit 5");


if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{

$new_date = vbdate('m.d.Y', $ev['dateline'], false, false);
$link_date = vbdate('Y-m-d', $ev['dateline'], false, false);
$news .= "<b>".$new_date."</b>"."<BR>";
$news .= "</b>".$ev['title']."<BR>";

}
}

echo "<A HREF=\"/forums/calendar.php?do=getinfo$ev[eventid]&day=$link_date&c=1\">$news</A>";
?>

But, the array, all 5 items, link to one day, the day of the last item. Sooo, how could we put in a check thingy to get a link to each event?

Pseudomizer
05-02-2004, 09:43 PM
Hmm, I fooled around with it to get it to work, or at least link correctly (for my site and my settings.)

echo "<hr><b><a href=\"http://www.xblgamers.com/forums/calendar.php?\">Latest Events</a> . . .</b><b><p>";




$events = $DB_site->query("select * from event order by dateline DESC limit 5");


if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{

$new_date = vbdate('m.d.Y', $ev['dateline'], false, false);
$link_date = vbdate('Y-m-d', $ev['dateline'], false, false);
$news .= "<b>".$new_date."</b>"."<BR>";
$news .= "</b>".$ev['title']."<BR>";

}
}

echo "<A HREF=\"/forums/calendar.php?do=getinfo$ev[eventid]&day=$link_date&c=1\">$news</A>";
?>

But, the array, all 5 items, link to one day, the day of the last item. Sooo, how could we put in a check thingy to get a link to each event?

This is very easy to answer. If you look at my original post you will see that i did put the echo with the link IN THE if and while loop. You placed it outside. Just have a look at my original code.

Cheers,

Curll
05-02-2004, 09:45 PM
Yeah...but....looking is hard :'(

Pseudomizer
05-02-2004, 09:48 PM
Yeah...but....looking is hard :'(

Sorry, i did not get this. Does it work now ? Or is something else wrong now ?

Cheers,

Curll
05-02-2004, 09:49 PM
Well, I had to add a $news = " "; before the other two 'cause it kept counting and adding to the $news.

And it works dandy now. Thanks!

Pseudomizer
05-02-2004, 10:07 PM
Well, I had to add a $news = " "; before the other two 'cause it kept counting and adding to the $news.

And it works dandy now. Thanks!

This was also in my script because i knew it would do that. But i am glad that you realized that.

I am happy that i could help you.

Cheers,

Richardg
05-03-2004, 12:02 AM
Hi Richard,

i have never done such a thing before but i can give you some guidance in which direction you should look to find the error. When you post something or you create a thread in all php files they are using the same function. Please have a closer look into this section:


$serveroffset = date('Z', TIMENOW) / 3600;

$fromdate = getdate(TIMENOW + (-12 - $serveroffset) * 3600);
$new_date = date('d-m-Y', TIMENOW + (-12 - $serveroffset) * 3600 );


In addition i would suggest that you look into the calendar_functions.php in your /includes directory.

Hope this helps.

Cheers,

Thanks - The calndar functions must hold the clue .. that will keep me quiet for a while! (sorry to interrupt the thread)

cheers

ryancooper
06-23-2004, 01:06 PM
OK I am a dolt when it comes to this stuff. Can someone post a php file that will show the next 5 events?

Pseudomizer
06-23-2004, 01:10 PM
Read post 18 and 21 and you are set.

Cheers,

ryancooper
06-23-2004, 01:34 PM
Read post 18 and 21 and you are set.

Cheers,
OK I am trying but this is what i get:
http://talkdisney.com/forums/test.php

here is the file i did.

The Coldwood
08-08-2004, 01:29 PM
Pseudomizer, you are the man!

Pseudomizer
08-08-2004, 03:05 PM
Pseudomizer, you are the man!

Where ever i can help.

Cheers,

upnorth
08-30-2004, 03:29 PM
any idea on how to get this working on a non-vB page?

Pseudomizer
08-30-2004, 03:42 PM
any idea on how to get this working on a non-vB page?

Sorry, but why do you ask this question? Did you read the subject of this thread? I would assume no. We are only talking about non-vB pages and how to implement such queries in there.

So please rephrase your question. Thanks.

Cheers,

upnorth
08-30-2004, 05:04 PM
Sorry My bad. Got so excited when I read the posts I didn't read the subject close enough. I'll give it a try and see if I can get it to work.

Sorry for that :nervous:

upnorth
08-30-2004, 05:23 PM
k hopefully I haven't overlooked anything so please be patient with me as this is all new to me.

I tried your code and it works fine. How hard would it be to only show todays events and the next 3 or 4 days. Make sense?

WildEye
01-15-2005, 09:16 PM
This is very easy to answer. If you look at my original post you will see that i did put the echo with the link IN THE if and while loop. You placed it outside. Just have a look at my original code.

Cheers,

I've been trying to get this to work now, as posted in #18, but i'm getting an error message:

Fatal error: Call to a member function on a non-object in /home/n4f/html/calendarexport.php on line 3

What am i doing wrong? Not very familiar with what to do... Shouldn't my databasename be somewhere? or... Any help appreciated.

echo "<hr><b><a href=\"http://www.mysite.com/forum/calendar.php?\">Latest Events</a> . . .</b><b><p>";
$events = $DB_site->query("select * from event order by dateline DESC limit 5");
if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$new_date = vbdate('m.d.Y', $ev['dateline'], false, false);
$link_date = vbdate('Y-m-d', $ev['dateline'], false, false);
$news .= "<b>".$new_date."</b>"."<BR>";
$news .= "</b>".$ev['title']."<BR>";
}
}
echo "<A HREF=\"/forum/calendar.php?do=getinfo$ev[eventid]&day=$link_date&c=1\">$news</A>";

Pseudomizer
01-15-2005, 09:41 PM
I've been trying to get this to work now, as posted in #18, but i'm getting an error message:

Fatal error: Call to a member function on a non-object in /home/n4f/html/calendarexport.php on line 3

What am i doing wrong? Not very familiar with what to do... Shouldn't my databasename be somewhere? or... Any help appreciated.

echo "<hr><b><a href=\"http://www.mysite.com/forum/calendar.php?\">Latest Events</a> . . .</b><b><p>";
$events = $DB_site->query("select * from event order by dateline DESC limit 5");
if ($DB_site->num_rows($events))
{
while ($ev = $DB_site->fetch_array($events))
{
$new_date = vbdate('m.d.Y', $ev['dateline'], false, false);
$link_date = vbdate('Y-m-d', $ev['dateline'], false, false);
$news .= "<b>".$new_date."</b>"."<BR>";
$news .= "</b>".$ev['title']."<BR>";
}
}
echo "<A HREF=\"/forum/calendar.php?do=getinfo$ev[eventid]&day=$link_date&c=1\">$news</A>";


Hi,

the DBsite command is using the SQL PHP class from VBulletin. If you have included the global.php you should not have the problems you have. Keep in mind that you have to change the directory to include the global.php if you are not in your forum home directory.

Cheers,

smdani
01-25-2005, 05:41 AM
I used the information on this post and it worked like a charm for me!
THANKS A LOT.

On showing users online code:
WHERE session.lastactivity > $online[datecut]
I cant found $online variable.
Which file must I include in order to work?

And, how can I show the total numer of users online?

Here another question:
Maybe this is not the correct thread, but I think you can help me because it is a very similar problem.
I would like to show TODAY BIRTHDAY's on a non-vb page.
What I dontknow how to do is to compare today date DATE(now), with users.birthday_search and find thos users whose celebrate their birthday.
Any help?

Thanks in advance.

Users online:


$onlineusers = $DB_site->query("
## GET ONLINE USERS ##
SELECT user.username, (user.options & $_USEROPTIONS[invisible]) AS invisible,
user.usergroupid, session.userid, session.lastactivity,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM ".TABLE_PREFIX."session AS session
LEFT JOIN ".TABLE_PREFIX."user AS user ON (user.userid = session.userid)
WHERE session.lastactivity > $online[datecut]
ORDER BY ".iif($permissions['genericpermissions'] & CANSEEHIDDEN, 'invisible ASC, ')."username ASC");


Total Threads:


$totalthreads = $DB_site->query("Select count(threadid) from thread where visible = '1' );


Cheers,