vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Calendar events on non-VB pages (https://vborg.vbsupport.ru/showthread.php?t=105215)

MamboCube 06-02-2006 08:45 AM

for my website i use this

Code:

<?php 
$host  = 'localhost';
$dbUser = 'db_user'; 
$dbPass = 'password';
$db = 'db_name';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());

$result = mysql_query("SELECT * FROM vb3_event order by dateline DESC LIMIT 10" ) or die(mysql_error()); 
while($row = mysql_fetch_array( $result )) {       
print  "<a href='http://www.DOMAIN.COM/FORUM_ADDRESS/calendar.php?do=getinfo&e=" . $row['eventid'] . "&c=2'>". $row['title'] . "</a><br>" ;
}
?>

this grabs the last events from the database, it does not use global.php

i find this works just as well

Zilvia 06-06-2006 05:34 AM

MamboCube: This actually worked on my CMS site, but it dosent display correctly. Its not in order and it will display old and out of date events. Is there a way to add a date and then order it from latest to oldest and have it remove the old events? I played around with it a bit but couldnt get it to work right with my limited knowledge. Thanks

MamboCube 06-06-2006 05:47 AM

have u put in this bit?:

Code:

order by dateline DESC LIMIT 10
because that should grab the last events and only show ten

rabidkevin 06-06-2006 07:22 PM

If you want it to list it with the date, and not show events which have already passed, use this code

Code:


<?php 
$host  = 'localhost';
$dbUser = 'username'; 
$dbPass = 'pass';
$db = 'database';
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());

$result = mysql_query("SELECT * FROM vb35_event where dateline_from >= UNIX_TIMESTAMP() order by dateline_from ASC LIMIT 10" ) or die(mysql_error()); 
while($row = mysql_fetch_array( $result )) {       
$dateevent = date('M j, Y', $row[dateline_from]);
print  "$dateevent - <a href='http://WWW.DOMAIN.COM/FORUMS/calendar.php?do=getinfo&e=" . $row['eventid'] . "&c=1'>". $row['title'] . "</a><br>" ;
}
?>


Zilvia 06-07-2006 01:22 AM

I have tried both of those options.

dateline dosent display in the correct order nor does dateline_from or to or really any other filds I tried.

rabidkevin 06-07-2006 01:54 PM

works for me... http://www.eternalbeats.net/home2.php
using the code i just pasted

Zilvia 06-09-2006 03:44 AM

Quote:

Originally Posted by rabidkevin
works for me... http://www.eternalbeats.net/home2.php
using the code i just pasted

Oh man! I read over and swore it was identical to what I had tried and retried many time. This got it working for me! You ROCK!

rabidkevin 06-09-2006 05:13 AM

no prob
if you wanna see it in action use http://www.eternalbeats.net/home.php now, i updated

also if someone could help with code to retrive the custom fields, that would be dope

helden 01-13-2007 10:28 AM

Final workin Code also for 3.6

sorry for my poor english

PHP Code:

<?php  
$host   
'localhost'
$dbUser 'user';   
$dbPass 'wort'
$db 'db666'
mysql_connect("$host""$dbUser""$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());

$result mysql_query("SELECT * FROM vb3_event where dateline_from >= UNIX_TIMESTAMP() order by dateline_from ASC LIMIT 10" ) or die(mysql_error());   
while(
$row mysql_fetch_array$result )) {    
$dateevent date('M j, Y'$row[dateline_from]);
print  
"$dateevent - <a href='http://www.deinehomepage.com/vbullitin/calendar.php?do=getinfo&e=" $row['eventid'] . "&c=1'>"$row['title'] . "</a><br>" ;
}
?>


LIMIT 10 say "show 10 dates" and is changebel

NorthwoodsFella 04-09-2007 04:46 AM

I was looking for a way to display the calendar events from a specific calendar on certain sub-forums. I looked and looked and tried dozens of "working code" examples, but could NOT get anything to work properly.

I found the previous example code to be very close, but I kept having problems with the date, so I made a couple of modifications to get it to work the way I wanted.

The following example will display the Calendar ID 3 events if the Forum ID is 3. This is done with two modifcations. A modification to the forumdisplay.php code and a modification to the ForumDisplay Template. I also set the number of event days to 45 because I have it set to '0' in the vb options.

forumdisplay.php
PHP Code:

if ($vbulletin->GPC['forumid'] == )
{

if (
$vbulletin->GPC['forumid'] == ) {$calendarid ;}

$host   "your_localhost";  
$dbUser "your_dbuuser";    
$dbPass "your_dbpass";  
$mydb "your_db";  

mysql_connect("$host""$dbUser""$dbPass") or die(mysql_error()); 
mysql_select_db("$mydb") or die(mysql_error());

$u TIMENOW;

$vbulletin->options['showevents']=45;

$futuredate = ($vbulletin->options['showevents'] * 86400)+$u;

$result mysql_query("SELECT * FROM event where (dateline_from+172800) >= UNIX_TIMESTAMP() 
AND dateline_from+86400 < 
$futuredate 
AND calendarid = 
$calendarid 
order by dateline_from ASC LIMIT 10" 
) or die(mysql_error());    

while(
$row mysql_fetch_array$result )) {     
$dateevent date('m-d-Y', ($row[dateline_from]+86400)); 
$upcomingevents "$upcomingevents"<a 
href='http://www.yourwebsite.com/calendar.php?do=getinfo&e=
$row[eventid]&c=$calendarid'>$row[title]</a>: " "$dateevent."<br>";





I use the same events format as the one used for index.php and have inserted it into the forumdisplay template.


ForumDisplay Template
PHP Code:

<!-- upcoming events -->
<if 
condition="$vbulletin->GPC['forumid'] == 3">

<
table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<
tbody>
    <
tr>
        <
td class="thead" colspan="2">
            <
a style="float:$stylevar[right]href="#top" onclick="return toggle_collapse('forumhome_events')"><img id="collapseimg_forumhome_events" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_events].gif" alt="" border="0" /></a>
            <if 
condition="$show['todaysevents']">$vbphrase[todays_events]<else /><phrase 1="$vboptions[showevents]">$vbphrase[upcoming_events_for_the_next_x_days]</phrase></if>
        </
td>
    </
tr>
</
tbody>
<
tbody id="collapseobj_forumhome_events" style="$vbcollapse[collapseobj_forumhome_events]">
    <
tr>
        <
td class="alt2"><a href="calendar.php$session[sessionurl_q]"><img src="$stylevar[imgdir_misc]/calendar.gif" alt="$vbphrase[calendar]border="0" /></a></td>
        <
td class="alt1" width="100%"><div class="smallfont">$upcomingevents</div></td>
    </
tr>
</
tbody>
</
table>
<
br>
</if>
<!-- / 
upcoming events --> 


This modification was installed on a board using 3.6.5.


All times are GMT. The time now is 09:06 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01217 seconds
  • Memory Usage 1,785KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete