SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast PenguinsRock's Avatar
    Join Date
    Apr 2010
    Location
    Scotland, UK
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anyone know of a good events calendar? (Just to display events, not a date picker)

    Hi,

    Can anyone point me in the direction of a decent PHP calendar that will display events which are stored in a MySQL database. Basically, I have a huge events database with masses of event-related information (including, obviously, eventID, eventDate and eventTitle type columns) and my clients want a calendar to display in the sidebar menu of their website. The idea is people can quickly look at a month, see at a glance which dates have an event and which dates don't, hover over a date that does have an event and get the title of the event for that day, then decide whether or not to click through for more details on that event. I see this a lot on conference centre websites and theatre websites etc.

    From my initial searches, there seem to be a lot of date pickers (for forms), and outlook-style add-your-own-events-to-this-calendar style calendars (for adding new events to a calendar via a website) out there, but I can't find much on simple calendars with a click on the date and it'll pass the event ID and take you to a new page with details of the event on it.

    Any ideas?

    Thanks,

    PenguinsRock

  2. #2
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That calendar looks like its from the days of DOS. You want a fully animated jquery calendar.

    Can someone please tell me what code I should insert in this functions.php file to make my users' classifieds ads expire after the final event date? I don't want my 'What's On' categories to contain events that have finished.

    The 'events' categories are all separated from 'listing' categories in my wordpress site, but I'm not sure if you need a specific metatag to help with this coding. Listing ads (as opposed to event ads) don't have dates. Listing ads run for 30, 90 or 365 days (admin decides). These need to expire as normal. But events should expire the date after the final show. The field for the last show is 'END DATE' on the 'Place an Ad' form. Not sure what the meta tag is for that either.

    Code:
    <?php 
    /*************************************************************
    * Do not modify unless you know what you're doing, SERIOUSLY!
    *************************************************************/
    error_reporting(E_ERROR);
    
    define('TAGKW_TEXT_COUNT',40);
    
    load_theme_textdomain('default');
    //load_textdomain( 'default', TEMPLATEPATH.'/en_US.mo' );
    // This theme uses post thumbnails
    add_theme_support( 'post-thumbnails' );
    // Add default posts and comments RSS feed links to head
    add_theme_support( 'automatic-feed-links' );
    global $blog_id;
    if(get_option('upload_path') && !strstr(get_option('upload_path'),'wp-content/uploads'))
    {
    	$upload_folder_path = "wp-content/blogs.dir/$blog_id/files/";
    }else
    {
    	$upload_folder_path = "wp-content/uploads/";
    }
    global $blog_id;
    if($blog_id){ $thumb_url = "&amp;bid=$blog_id";}
    if ( function_exists( 'add_theme_support' ) ){
    	add_theme_support( 'post-thumbnails' );
    	}
    ### Rating Logs Table Name
    global $wpdb;
    $term_icon_column=$wpdb->get_var("SHOW COLUMNS FROM $wpdb->terms where field='term_icon'");
    if(!$term_icon_column)
    {
    	$wpdb->query("ALTER TABLE $wpdb->terms ADD `term_icon` TEXT NULL DEFAULT NULL");
    }
    $rating_table_name = $wpdb->prefix.'ratings';
    require(TEMPLATEPATH . "/product_menu.php");
    
    
    if(get_option('ptthemes_captcha_dislay')=='No'){}else
    {
    include_once (TEMPLATEPATH . '/library/captcha/captcha_function.php');
    }
    include_once (TEMPLATEPATH . '/language.php');
    
    include_once (TEMPLATEPATH . '/library/includes/post_custom_settings.php');  // custom fields settings + database settings
    include_once (TEMPLATEPATH . '/library/includes/post_custom_fields.php');  // custom fields HTML Tag coding
    
    // Theme variables
    include_once (TEMPLATEPATH . '/library/functions/theme_variables.php');
    //custom post type
    include_once (TEMPLATEPATH . '/library/functions/custom_post_type.php');
    
    //** ADMINISTRATION FILES **//
    
    if(file_exists($functions_path . 'multi_city_functions.php'))
    {
    	include_once ($functions_path . 'multi_city_functions.php');	
    }
    // Theme admin functions
    include_once ($functions_path . 'admin_functions.php');
    // Theme admin options
    include_once ($functions_path . 'admin_options.php');
    // Theme admin Settings
    include_once ($functions_path . 'admin_settings.php');
    //** FRONT-END FILES **//
    // Widgets
    include_once ($functions_path . 'widgets_functions.php');
    // Custom
    include_once ($functions_path . 'custom_functions.php');
    // Comments
    include_once ($functions_path . 'comments_functions.php');
    include_once ($functions_path . 'yoast-canonical.php');
    include_once ($functions_path . 'yoast-breadcrumbs.php');
    include_once ($functions_path . 'most-popular.php');
    include_once ($functions_path . 'image_resizer.php');
    
    include_once (TEMPLATEPATH . '/library/rating/post_rating.php');
    
    //Listing filters type
    include_once (TEMPLATEPATH . '/library/functions/listing_filters.php');
    
    //theme.php
    function autoinstall_admin_header()
    {
    	global $wpdb;
    	if(strstr($_SERVER['REQUEST_URI'],'themes.php') && $_REQUEST['template']=='' && $_GET['page']=='') 
    	{
    		
    		if($_REQUEST['dummy']=='del')
    		{
    			delete_dummy_data();	
    			$dummy_deleted = '<p><b>All Dummy data has been removed from your database successfully!</b></p>';
    		}
    		if($_REQUEST['dummy_insert'])
    		{
    			include_once (TEMPLATEPATH . '/auto_install.php');
    			$wpdb->query("INSERT INTO `".$multicity_db_table_name."` (`city_id`, `cityname`, `lat`, `lng`, `scall_factor`, `is_zoom_home`, `categories`) VALUES (NULL, 'Philadelphia', '39.953438023308465', '-75.14579772949219', '13', 'Yes', '')");  //MULTI CITY DATA INSETS
    		}
    		if($_REQUEST['activated']=='true')
    		{
    			$theme_actived_success = '<p class="message">Theme activated successfully.</p>';	
    		}
    		$post_counts = $wpdb->get_var("select count(post_id) from $wpdb->postmeta where (meta_key='pt_dummy_content' || meta_key='tl_dummy_content') and meta_value=1");
    		if($post_counts>0)
    		{
    			$dummy_data_msg = '<p> <b>Sample data has been populated on your site. Wish to delete sample data?</b><br />If you have problem with image, please copy images/dummy folder to wp-content/uploads <br />  <a class="button_delete" href="'.site_url().'/wp-admin/themes.php?dummy=del">Yes Delete Please!</a><p>';
    		}else
    		{
    			$dummy_data_msg = '<p> <b>Would you like to auto install this theme and populate sample data on your site?</b> <br />  <a class="button_insert" href="'.site_url().'/wp-admin/themes.php?dummy_insert=1">Yes, insert sample data please</a></p>';
    		}
    
    	define('THEME_ACTIVE_MESSAGE','
    	<style>
    	.highlight { width:60% !important; background:#FFFFE0 !important; overflow:hidden; display:table; border:2px solid #558e23 !important; padding:15px 20px 0px 20px !important; -moz-border-radius:11px  !important;  -webkit-border-radius:11px  !important; } 
    	.highlight p { color:#444 !important; font:15px Arial, Helvetica, sans-serif !important; text-align:center;  } 
    	.highlight p.message { font-size:13px !important; }
    	.highlight p a { color:#ff7e00; text-decoration:none !important; } 
    	.highlight p a:hover { color:#000; }
    	.highlight p a.button_insert 
    		{ display:block; width:230px; margin:10px auto 0 auto;  background:#5aa145; padding:10px 15px; color:#fff; border:1px solid #4c9a35; -moz-border-radius:5px;  -webkit-border-radius:5px;  } 
    	.highlight p a:hover.button_insert { background:#347c1e; color:#fff; border:1px solid #4c9a35;   } 
    	.highlight p a.button_delete 
    		{ display:block; width:140px; margin:10px auto 0 auto; background:#dd4401; padding:10px 15px; color:#fff; border:1px solid #9e3000; -moz-border-radius:5px;  -webkit-border-radius:5px;  } 
    	.highlight p a:hover.button_delete { background:#c43e03; color:#fff; border:1px solid #9e3000;   } 
    	#message0 { display:none !important;  }
    	</style>
    	
    	<div class="updated highlight fade"> '.$theme_actived_success.$dummy_deleted.$dummy_data_msg.'</div>');
    		echo THEME_ACTIVE_MESSAGE;
    	}
    }
    add_action("admin_head", "autoinstall_admin_header"); // please comment this line if you wish to DEACTIVE SAMPLE DATA INSERT.
    
    function delete_dummy_data()
    {
    	global $wpdb;
    	//delete_option('sidebars_widgets'); //delete widgets
    	$productArray = array();
    	$pids_sql = "select p.ID from $wpdb->posts p join $wpdb->postmeta pm on pm.post_id=p.ID where (meta_key='pt_dummy_content' || meta_key='tl_dummy_content') and meta_value=1";
    	$pids_info = $wpdb->get_results($pids_sql);
    	foreach($pids_info as $pids_info_obj)
    	{
    		wp_delete_post($pids_info_obj->ID);
    	}
    }
    
    /////////////////PLACE PRICE SETTINGS CODING START/////////////////
    global $wpdb,$table_prefix;
    $price_db_table_name = $table_prefix . "price";
    if($wpdb->get_var("SHOW TABLES LIKE \"$price_db_table_name\"") != $price_db_table_name)
    {
    	$price_table = 'CREATE TABLE IF NOT EXISTS `'.$price_db_table_name.'` (
    	  `pid` int(11) NOT NULL AUTO_INCREMENT,
    	  `title` varchar(255) NOT NULL,
    	  `amount` float(12,2) NOT NULL,
    	  `cat` varchar(255) NOT NULL,
    	  `status` tinyint(2) NOT NULL DEFAULT \'1\',
    	  `days` int(10) NOT NULL,
    	   `is_featured` tinyint(4) NOT NULL DEFAULT \'0\',
    	   `title_desc` text NOT NULL,
    	  PRIMARY KEY (`pid`)
    	)';
    	$wpdb->query($price_table);
    	
    	$price_insert = '
    	INSERT INTO `'.$price_db_table_name.'` (`pid`, `title`, `amount`, `status`, `days`,`is_featured`) VALUES
    	(1, "Free", 0.00, 1, 30, 0),
    	(2, "Featured", 10.00, 1, 90, 1)';
    	$wpdb->query($price_insert);
    }else
    {
    	$wpdb->query("ALTER TABLE $price_db_table_name ADD `is_featured` TINYINT( 4 ) NOT NULL DEFAULT '0'");
    	$wpdb->query("ALTER TABLE $price_db_table_name ADD `title_desc` TEXT NOT NULL");
    	$wpdb->query("ALTER TABLE $price_db_table_name ADD `cat` varchar( 255 ) NOT NULL");
    	 
    }
    /////////////////PLACE PRICE SETTINGS CODING END/////////////////
    /////////////////PLACE EXPIRY SETTINGS CODING START/////////////////
    global $table_prefix, $wpdb;
    $table_name = $table_prefix . "place_expire_session";
    $current_date = date('Y-m-d');
    if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
    {
       global $table_prefix, $wpdb,$table_name;
       $sql = 'DROP TABLE `' . $table_name . '`';  // drop the existing table
       mysql_query($sql);
    
    	$sql = 'CREATE TABLE `'.$table_name.'` (
    			`session_id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    			`execute_date` DATE NOT NULL ,
    			`is_run` TINYINT( 4 ) NOT NULL DEFAULT "0"
    			) ENGINE = MYISAM ;';
       mysql_query($sql);
    }
    $today_executed = $wpdb->get_var("select session_id from $table_name where execute_date=\"$current_date\"");
    if($today_executed && $today_executed>0)
    {
    }else
    {
    	if(get_option('ptthemes_listing_expiry_disable'))
    	{
    		if(get_option('ptthemes_listing_preexpiry_notice_disable'))
    		{
    			$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
    			if($number_of_grace_days=='')
    			{
    				$number_of_grace_days=1;	
    			}
    			$postid_str = $wpdb->get_results("select p.ID,p.post_author,p.post_date, p.post_title from $wpdb->posts p where (p.post_type='post' or p.post_type='event') and p.post_status='publish' and datediff(\"$current_date\",date_format(p.post_date,'%Y-%m-%d')) > (select meta_value from $wpdb->postmeta pm where post_id=p.ID and meta_value>0  and meta_key='alive_days')-$number_of_grace_days");
    			foreach($postid_str as $postid_str_obj)
    			{
    				$ID = $postid_str_obj->ID;
    				$post_author = $postid_str_obj->post_author;
    				$post_date = date('dS m,Y',strtotime($postid_str_obj->post_date));
    				$post_title = $postid_str_obj->post_title;
    				$userinfo = $wpdb->get_results("select user_email,display_name,user_login from $wpdb->users where ID=\"$ID\"");
    				$user_email = $userinfo[0]->user_email;
    				$display_name = $userinfo[0]->display_name;
    				$user_login = $userinfo[0]->user_login;
    				
    				$fromEmail = get_site_emailId();
    				$fromEmailName = get_site_emailName();
    				$alivedays = get_post_meta($ID,'alive_days',true);
    				$productlink = get_permalink($ID);
    				$loginurl = site_url().'/?ptype=login';
    				$siteurl = site_url();
    				$client_message = "<p>Dear $display_name,<p><p>Your listing -<a href=\"$productlink\"><b>$post_title</b></a> posted on  <u>$post_date</u> for $alivedays days is scheduled to expire in $number_of_grace_days day(s). When your listing expires, it will no longer appear on the site.</p>
    				<p> If you want your ad to continue, please login to your member area of our site and renew. You canlogin here <a href=\"$loginurl\">$loginurl</a>.</p>
    				<p>Your login ID is <b>$user_login</b> and Email ID is <b>$user_email</b>.</p>
    				<p>Thank you,<br /><a href=\"$siteurl\">$fromEmailName</a>.</p>";
    				
    				$subject = 'Place listing expiration Notification';
    				$headers  = 'MIME-Version: 1.0' . "\r\n";
    				$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
    				$headers .= 'To: '.$display_name.' <'.$user_email.'>' . "\r\n";
    				$headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\r\n";
    				@mail($user_email,$subject,$client_message,$headers);///To client email
    			}
    		}
    		$postid_str = $wpdb->get_var("select group_concat(p.ID) from $wpdb->posts p where p.post_type='post' and p.post_status='publish' and datediff(\"$current_date\",date_format(p.post_date,'%Y-%m-%d')) > (select meta_value from $wpdb->postmeta pm where post_id=p.ID  and meta_key='alive_days')");
    	
    		if($postid_str)
    		{
    			$listing_ex_status = get_option('ptthemes_listing_ex_status');
    			if($listing_ex_status=='')
    			{
    				$listing_ex_status = 'draft';	
    			}
    			$wpdb->query("update $wpdb->posts set post_status=\"$listing_ex_status\" where ID in ($postid_str)");
    		}
    		$wpdb->query("insert into $table_name (execute_date,is_run) values (\"$current_date\",'1')");
    	}
    }
    /////////////////PLACE EXPIRY SETTINGS CODING END/////////////////
    ?>
    This is the code for functions.php. I would love some help. I'm looking for a calendar too. I'll try looking up jquery calendars...

  3. #3
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Enthusiast PenguinsRock's Avatar
    Join Date
    Apr 2010
    Location
    Scotland, UK
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Just wanted to say that I found a really great PHP calendar tutorial here: http://www.phpjabbers.com/phpexamples.php

    There's also a really good additional SQL functionality bit of code within the comments - look for a comment by Jarle Hagavei.

    For anyone interested, here's my final code (slightly tweaked from the original version to match the look of my current project) which produces a calendar with events brought in from a pre-existing events database.

    PHP Code:

    <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/dbconnect.inc.php';
    include_once 
    $_SERVER['DOCUMENT_ROOT'] . '/includes/helpers.inc.php'?>

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Calendar</title>
    </head>

    <body>

    <?php
    $monthNames 
    = Array("Jan""Feb""Mar""Apr""May""Jun""Jul"
    "Aug""Sept""Oct""Nov""Dec");
    ?>

    <?php
    if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
    if (!isset(
    $_REQUEST["year"])) $_REQUEST["year"] = date("Y");
    ?>

    <?php
    $cMonth 
    $_REQUEST["month"];
    $cYear $_REQUEST["year"];

    $prev_year $cYear;
    $next_year $cYear;
    $prev_month $cMonth-1;
    $next_month $cMonth+1;

    if (
    $prev_month == ) {
        
    $prev_month 12;
        
    $prev_year $cYear 1;
    }
    if (
    $next_month == 13 ) {
        
    $next_month 1;
        
    $next_year $cYear 1;
    }
    ?>

    <table width="220px">
    <tr>
    <td align="center">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse; font-family:Arial, Helvetica, sans-serif;">


    <tr align="center" height="15px;" style="background-color:#009933; color:#fff;">

    <td colspan="1"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month="$prev_month "&year=" $prev_year?>" style="color:#FFFFFF; text-decoration:none;">prev</a></td>

    <td colspan="5" style="font-size:14px; font-weight:800;">
    <strong><?php echo $monthNames[$cMonth-1].' '.$cYear?></strong>
    </td>

    <td colspan="1">
    <a href="<?php echo $_SERVER["PHP_SELF"] . "?month="$next_month "&year=" $next_year?>" style="color:#FFFFFF; text-decoration:none;">next</a>
    </td>

    </tr>


    <tr height="15px" style="padding:0px 1px; background:#fff; color:#000; font-weight:300; font-size:12px;">
    <td align="center" width="30px">sun</td>
    <td align="center" width="30px">mon</td>
    <td align="center" width="30px">tue</td>
    <td align="center" width="30px">wed</td>
    <td align="center" width="30px">thu</td>
    <td align="center" width="30px">fri</td>
    <td align="center" width="30px">sat</td>
    </tr>

    <?php
    $timestamp 
    mktime(0,0,0,$cMonth,1,$cYear);
    $maxday date("t",$timestamp);
    $thismonth getdate ($timestamp);
    $startday $thismonth['wday'];

    for (
    $i=0$i<($maxday+$startday); $i++) {

    if(
    $cMonth 10){
    $month_formated "0$cMonth";
    }else{
    $month_formated $cMonth;
    }    

    if((
    $i $startday 1) < 10){
    $day_formated "0".($i $startday 1)."";
    }else{
    $day_formated = ($i $startday 1);    
    }

    $dato_formated "$cYear-$month_formated-$day_formated";

    $get_calendar_data mysqli_query($link"SELECT event_date, event_title, event_id FROM events WHERE event_date='$dato_formated'");

    if (
    mysqli_num_rows($get_calendar_data) > 0)
        {
         
    $bgcolor "#b4ffc8";
         
    $fontweight "700";
        }
        
        else
        {    
        
    $bgcolor "#fff";
        
    $fontweight "300";
        }    

    $calendar_data mysqli_fetch_assoc($get_calendar_data);
    $hover $calendar_data['event_title'];
    $eventlink $calendar_data['event_id'];    


    if((
    $i 7) == ) echo "<tr>\n";
    if(
    $i $startday) echo "<td style=\"border:1px solid #66CC99;\"></td>\n";

    else

    echo 
    "
    <td height='30px' align='center' valign='middle' style='background-color:
    $bgcolor; border:1px solid #66CC99; font-size:14px; font-weight:$fontweight;'>
    <a title='
    $hover' style='text-decoration:none; color:#000;' href='../events/?event_id=$eventlink&action=Details'>". ($i $startday 1) . "
    </a>
    </td>\n"
    ;
    if((
    $i 7) == ) echo "</tr>\n";
    }

    ?>

    </table>
    </td>
    </tr>
    </table>

    </body>
    </html>
    Feel free to use it if you think it'll help in your project.

    PenguinsRock

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can give you two options for event calendar.

    1.The first one is online events planner where you need to sign up for a new account after which you can create your own calendar and manage your events. Please follow this link. http://easycalculation.com/event/event-calendar.php.

    2.The second one is the script that is written in PHP. Allow visitors of your website to quickly know what events are planned and when.

    You can use any of the scripts listed here.
    http://www.hscripts.com/scripts/php/...screenshot.php

    You need to download it. From admin panel you can manage events, change calendar colors, set size, change new password. Add some lines in the file where you want HEC (Event Planner/Schedular) to be displayed.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •