Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 10:03:12 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149631 Posts in 21098 Topics by 7537 Members
Latest Member: lotte2
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Event Calendar Descriptions  (Read 1496 times)
amiracle

Offline Offline

Posts: 10


« on: April 09, 2008, 06:16:27 PM »

I am trying to utilize the event calendar to list golf league events and cannot seem to figure out how the module uses the description other than for listing the description on the page.

What I want to do is to have a page full of 1-liner events without descriptions but with every event being a link that would link to the description similar to how the News module works.
Logged
marathoner

Offline Offline

Posts: 495


« Reply #1 on: April 09, 2008, 07:02:05 PM »

You might want to use an approach similar to NewsAnywhere. It simply queries a table and displays the results using whatever syntax that you want. I use this approach on a calendar to show either the full calendar or just a listing of the events.

Full calendar:
http://www.secondsoletotalsports.com/pages/events/events-calendar-new.php

Event Listing Only:
http://www.secondsoletotalsports.com/pages/events/events-list.php
Logged
jmcall10

Offline Offline

Posts: 18


« Reply #2 on: April 11, 2008, 11:43:42 AM »

Wow!

how did you do this?

I love it! Smiley

Logged
marathoner

Offline Offline

Posts: 495


« Reply #3 on: April 12, 2008, 02:51:03 AM »

I just did what I suggested to you. Keep in mind that I use a different calendar (Another Calendar) but the concept is the same. I just tweaked the News Anywhere SQL to extract date from the calendar table and then formated the output to achieve the results.

Keep in mind that this approach requires a little coding on your part and isn't standard WB. PM me for details if you need.
Logged
jmcall10

Offline Offline

Posts: 18


« Reply #4 on: April 15, 2008, 09:16:14 AM »

Hi marathoner,

I was wondering if you could help me get a similar effect for the calendar description page you have?

I like the way you have it split into months and then the events for that month on this page:

http://www.secondsoletotalsports.com/pages/events/events-list.php

Could you post the code you use for this and is this a "code" page or something else?

Thanks in advance

jmcall10



Logged
marathoner

Offline Offline

Posts: 495


« Reply #5 on: April 15, 2008, 02:36:30 PM »

There's really nothing special here. It's simply the News Anywhere snippet modified to query the calendar table and then format it the way that I wanted. You'll see that I did apply a little logic to look at the month while formating. I also apply a class name (either 'even' or 'odd') so that every other line is displayed with a different background color.

I simply created the function below (you'll need to modify to meet your needs) and then have a code section that calls this function. You'll also see a variable ($crrc) that I created since I call this function for different domains and wanted a single function that I could use anywhere. Obviously, you can ignore anything related to this variable.

Code:
function event_cal_list($crrc = false) {
/*
    Below are the table fields
    SELECT `id`,`start_time`,`short_description`,`long_description`,`link_http`,`link_text`,`type` FROM `mod_event_calendar`

    Below returns the distinct months and years
    SELECT DISTINCT DATE_FORMAT(FROM_UNIXTIME(start_time),'%M %Y') AS x FROM mod_event_calendar ORDER BY start_time DESC

    Below selects events today or later
    SELECT * FROM mod_event_calendar WHERE (FROM_UNIXTIME(start_time) >= now())

    Below selects events from a specific month and year
    SELECT * FROM mod_event_calendar WHERE ("October 2007"=DATE_FORMAT(FROM_UNIXTIME(start_time),'%M %Y'))

            mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )

            $sql = "SELECT id,start_time,end_time,short_description,long_description,link_text,link_http,type FROM "
                            .TABLE_PREFIX
                            ."mod_event_calendar WHERE ((start_time < "
                            .mktime(0,0,0,$this->month+1,1,$this->year)
                            ." AND start_time > "
                            .mktime(0,0,0,$this->month-1,$days,$this->year)
                            .") OR (end_time < "
                            .mktime(0,0,0,$this->month+1,1,$this->year)
                            ." AND end_time > "
                            .mktime(0,0,0,$this->month-1,$days,$this->year)
                            .")) AND language = '"
                            .$this->language
                            ."' ORDER BY start_time;";

            $dfd = "SELECT id,start_time,end_time,short_description,long_description,link_text,link_http,type FROM "
                            .TABLE_PREFIX
                            ."mod_event_calendar WHERE ((start_time < "
                            .mktime(0,0,-1,date('n')+4,1,date('Y'))
                            ." AND start_time > "
                            .mktime(0,0,0,date('n'),1,date('Y'))
                            ."' ORDER BY start_time;";

*/

global $database;

$output = "<div class=\"cal\">\n";

$table_header = "<table rules=\"rows\">\n<colgroup valign=\"top\">\n<col width=\"50\"></col>\n<col width=\"34\"></col></colgroup>\n";
$table_footer = "</table>\n";

if ($crrc == true) {
$query = "SELECT * FROM ".TABLE_PREFIX."mod_event_calendar WHERE (start_time > ".date('U')." AND start_time < ".mktime(0,0,-1,date('n')+4,1,date('Y')).") ORDER BY start_time ASC;";
} else {
$query = "SELECT * FROM ".TABLE_PREFIX."mod_event_calendar WHERE (FROM_UNIXTIME(`start_time`) >= now()) ORDER BY `start_time` ASC;";
}

$error = mysql_error();
if (!$result = mysql_query($query)) {
  print "$error";
  exit;
}

while($data = mysql_fetch_object($result)) {
  $id = $data->id;
  $mon = date("M", $data->start_time);
  $date = date("j", $data->start_time);
  $dow = date("D", $data->start_time);
  $month = date("F", $data->start_time);
  $year =  date("Y", $data->start_time);
  $month_year =  date("F Y", $data->start_time);
  $short_description = $data->short_description;
  $long_description = $data->long_description;
  $link_http = $data->link_http;
  $type = $data->type;
  $details = $short_description." ".$long_description." <a href=\"http://".$link_http."\" target=\"_blank\">".$link_http."</a>";

if ($monthyear_counter !== $month_year) {
$row_num = "odd";
$output .= is_null($monthyear_counter) ? $table_header : $table_footer.$table_header;
$monthyear_counter = $month_year;
$output .= "<tr><th colspan=\"3\">".$month_year."</th></tr>\n";
}
$row_num = $row_num == "even" ? "odd" : "even";
$output .= "<tr class=\"".$row_num."\">\n <td>".$mon."&nbsp;".$date."</td>\n";
$output .= " <td>".$dow."</td>\n";
$output .= " <td>".$details."</td>\n</tr>\n";
}
$output .= $table_footer."</div>";
echo $output;
// -->
}
// End Event_cal_list
« Last Edit: April 15, 2008, 11:15:35 PM by marathoner » Logged
jmcall10

Offline Offline

Posts: 18


« Reply #6 on: April 15, 2008, 11:03:09 PM »

Thank you for posting that, however I have many questions still.

First of all can you check the code is posted correctly as there seems to be some funny stuff at the top.

Secondly, if the code is correct, where do I paste it?

Because if i post it into a "code" page then it doesnt work and if I post it into my template directly it doesnt work.

Sorry if this is time consuming but I really like this and would like to implement something similar

Thanks in advance

jmcall10
Logged
marathoner

Offline Offline

Posts: 495


« Reply #7 on: April 15, 2008, 11:38:32 PM »

I corrected the function code in my post above (I cut'n'pasted too fast...sorry).

There are lot's of options here. I created a function because I wanted to reuse the function in different places. You could also simply insert the code into a code section without defining a function. I'll go thru both approaches:

You create this function just like any other PHP function. I created a new file called customfrontend.func tions.php in the framework directory (to keep it separate from standard code) where I have the code above. Then you need to make sure that you modify your root directory index.php file to load the customfrontend.func tions.php (it already loads the standard frontend.functions. php so just add a line beneath that so it will look something like this:
Code:
require(WB_PATH.'/framework/frontend.functions.php');
require(WB_PATH.'/framework/customfrontend.functions.php');

If you simply want to use this on one page, then you would insert the code (without defining a function) into a code section something like this:
Code:
global $database;

$output = "<div class=\"cal\">\n";

$table_header = "<table rules=\"rows\">\n<colgroup valign=\"top\">\n<col width=\"50\"></col>\n<col width=\"34\"></col></colgroup>\n";
$table_footer = "</table>\n";

if ($crrc == true) {
$query = "SELECT * FROM ".TABLE_PREFIX."mod_event_calendar WHERE (start_time > ".date('U')." AND start_time < ".mktime(0,0,-1,date('n')+4,1,date('Y')).") ORDER BY start_time ASC;";
} else {
$query = "SELECT * FROM ".TABLE_PREFIX."mod_event_calendar WHERE (FROM_UNIXTIME(`start_time`) >= now()) ORDER BY `start_time` ASC;";
}

$error = mysql_error();
if (!$result = mysql_query($query)) {
  print "$error";
  exit;
}

while($data = mysql_fetch_object($result)) {
  $id = $data->id;
  $mon = date("M", $data->start_time);
  $date = date("j", $data->start_time);
  $dow = date("D", $data->start_time);
  $month = date("F", $data->start_time);
  $year =  date("Y", $data->start_time);
  $month_year =  date("F Y", $data->start_time);
  $short_description = $data->short_description;
  $long_description = $data->long_description;
  $link_http = $data->link_http;
  $type = $data->type;
  $details = $short_description." ".$long_description." <a href=\"http://".$link_http."\" target=\"_blank\">".$link_http."</a>";

if ($monthyear_counter !== $month_year) {
$row_num = "odd";
$output .= is_null($monthyear_counter) ? $table_header : $table_footer.$table_header;
$monthyear_counter = $month_year;
$output .= "<tr><th colspan=\"3\">".$month_year."</th></tr>\n";
}
$row_num = $row_num == "even" ? "odd" : "even";
$output .= "<tr class=\"".$row_num."\">\n <td>".$mon."&nbsp;".$date."</td>\n";
$output .= " <td>".$dow."</td>\n";
$output .= " <td>".$details."</td>\n</tr>\n";
}
$output .= $table_footer."</div>";
echo $output;
Logged
jmcall10

Offline Offline

Posts: 18


« Reply #8 on: April 16, 2008, 12:20:47 AM »

Ok I'm about to Throw.PC(OutOf(window))

I created customfrontend.func tions.php with:
Code:
function event_cal_list($crrc = false) {
/*
    Below are the table fields
    SELECT `id`,`start_time`,`short_description`,`long_description`,`link_http`,`link_text`,`type` FROM `mod_event_calendar`

    Below returns the distinct months and years
    SELECT DISTINCT DATE_FORMAT(FROM_UNIXTIME(start_time),'%M %Y') AS x FROM mod_event_calendar ORDER BY start_time DESC

    Below selects events today or later
    SELECT * FROM mod_event_calendar WHERE (FROM_UNIXTIME(start_time) >= now())

    Below selects events from a specific month and year
    SELECT * FROM mod_event_calendar WHERE ("October 2007"=DATE_FORMAT(FROM_UNIXTIME(start_time),'%M %Y'))

            mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )

            $sql = "SELECT id,start_time,end_time,short_description,long_description,link_text,link_http,type FROM "
                            .TABLE_PREFIX
                            ."mod_event_calendar WHERE ((start_time < "
                            .mktime(0,0,0,$this->month+1,1,$this->year)
                            ." AND start_time > "
                            .mktime(0,0,0,$this->month-1,$days,$this->year)
                            .") OR (end_time < "
                            .mktime(0,0,0,$this->month+1,1,$this->year)
                            ." AND end_time > "
                            .mktime(0,0,0,$this->month-1,$days,$this->year)
                            .")) AND language = '"
                            .$this->language
                            ."' ORDER BY start_time;";

            $dfd = "SELECT id,start_time,end_time,short_description,long_description,link_text,link_http,type FROM "
                            .TABLE_PREFIX
                            ."mod_event_calendar WHERE ((start_time < "
                            .mktime(0,0,-1,date('n')+4,1,date('Y'))
                            ." AND start_time > "
                            .mktime(0,0,0,date('n'),1,date('Y'))
                            ."' ORDER BY start_time;";

*/

global $database;

$output = "<div class=\"cal\">\n";

$table_header = "<table rules=\"rows\">\n<colgroup valign=\"top\">\n<col width=\"50\"></col>\n<col width=\"34\"></col></colgroup>\n";
$table_footer = "</table>\n";

if ($crrc == true) {
$query = "SELECT * FROM ".TABLE_PREFIX."mod_event_calendar WHERE (start_time > ".date('U')." AND start_time < ".mktime(0,0,-1,date('n')+4,1,date('Y')).") ORDER BY start_time ASC;";
} else {
$query = "SELECT * FROM ".TABLE_PREFIX."mod_event_calendar WHERE (FROM_UNIXTIME(`start_time`) >= now()) ORDER BY `start_time` ASC;";
}

$error = mysql_error();
if (!$result = mysql_query($query)) {
  print "$error";
  exit;
}

while($data = mysql_fetch_object($result)) {
  $id = $data->id;
  $mon = date("M", $data->start_time);
  $date = date("j", $data->start_time);
  $dow = date("D", $data->start_time);
  $month = date("F", $data->start_time);
  $year =  date("Y", $data->start_time);
  $month_year =  date("F Y", $data->start_time);
  $short_description = $data->short_description;
  $long_description = $data->long_description;
  $link_http = $data->link_http;
  $type = $data->type;
  $details = $short_description." ".$long_description." <a href=\"http://".$link_http."\" target=\"_blank\">".$link_http."</a>";

if ($monthyear_counter !== $month_year) {
$row_num = "odd";
$output .= is_null($monthyear_counter) ? $table_header : $table_footer.$table_header;
$monthyear_counter = $month_year;
$output .= "<tr><th colspan=\"3\">".$month_year."</th></tr>\n";
}
$row_num = $row_num == "even" ? "odd" : "even";
$output .= "<tr class=\"".$row_num."\">\n <td>".$mon."&nbsp;".$date."</td>\n";
$output .= " <td>".$dow."</td>\n";
$output .= " <td>".$details."</td>\n</tr>\n";
}
$output .= $table_footer."</div>";
echo $output;
// -->
}
// End Event_cal_list


I added this line to my root index.php

Code:
require(WB_PATH.'/framework/customfrontend.functions.php');

I then added this line to my template:

Code:
event_cal_list();

and nothing!

Sad

I notice that a lot of the code is commented out, is this normal

Im so sorry if this is wasting your time. I appreciate the assistance

jmcall10
Logged
jmcall10

Offline Offline

Posts: 18


« Reply #9 on: April 16, 2008, 12:45:58 AM »

also i checked my database backend and cannot find a table called "mod_event_calendar" all i have is "mod_event_dates" and " mod_event_settings"

Im so confussed now and really want to get this working as it is really fresh looking Smiley

jmcall10
Logged
marathoner

Offline Offline

Posts: 495


« Reply #10 on: April 16, 2008, 12:52:22 AM »

As I mentioned above...I use a different calendar system and included this as an example of what I did. You'll need to modify based on what table you want to query, and relevant field names, and the formating that you want.
Logged
jmcall10

Offline Offline

Posts: 18


« Reply #11 on: April 16, 2008, 12:57:35 AM »

Ok thanks for your help on this Marathoner. Can I ask what calendar system you used?
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!