Church Website

Post links to sites running CMS in all its glory.
Post Reply
matthewb

Church Website

Post by matthewb »

I've used CMSMS to produce a website for the church where I work (Church of England, located in Brentwood, Essex, UK).

You can take a look at http://www.st-thomas.org.uk

I've modified the php in a few places, notably
  • I changed the bulletmenu plugin so that each top level list item has its own id, so I could use different colours in the stylesheet
  • I modified the news and calendar modules to give a rudimentary page control
  • I added a week view to the calendar module which also grabs information from an external feed (giving each day its designation in the ecclesiastical calendar) and incorporates weekly recurring events which haven't been added to the database.
  • I also added (without any mods to the php) a feature to let users choose their preferred calendar view to use as the default.
  • Again without actually modding the php I added icons indicating whether events are am, pm or all day.
At some point I ought to upgrade to the stable release, but I'm not in a hurry as it all seems to be working fine. It does seem to run quite slowly sometimes, especially the admin panel, but I think that is a hosting issue.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Church Website

Post by tsw »

nice, clean and informative. with few nice pictures.

also noticed slowness on one occasion, most probably server related...
Muzzy

Re: Church Website

Post by Muzzy »

Hi Matthew.

A most worthy and excellent site.
The mods you hace done look stunning and are very useful. I like the Google Maps inclusion, perhaps you could give me a pointer as to how you implemented in your page. I tried to do it last week, but couldn't get it to work.

Bless you.
Mike.
matthewb

Re: Church Website

Post by matthewb »

Google maps was tricky to get working. Here's what I did:

Create a special template with an html blob in the header for the java, and an onload call to the mapload function in the body tag. You can see the full java in the source for my page (there is quite a lot for all the points I set up!) but the main bit is:

Code: Select all

<__script__ src="http://maps.google.com/maps?file=api&v=2&key=insert_the_api_key_which_you_have_obtained_from_google" type="text/javascript">
</__script><__script__ type="text/javascript">
    //<![CDATA[
    var map;
    function loadmap() {
      if (GBrowserIsCompatible()) {
        document.getElementById("map").innerHTML="";
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(51.619472,0.304472), 15);
        map.addControl(new GLargeMapControl());

etc. etc. etc.
Optional: Create a html blob to insert in the page. I use a blob because the FCK editor seems to strip out tags for some reason, so it is easiest to turn the editor off to create the blob, turn it back on then leave the blob well alone!

Code: Select all

<__script__ language="javascript" type="text/javascript">
<!--
document.write('<p style="color: red; font-style: italic;">Loading map...</p>')
-->
</__script><noscript>Javascript is needed to display the map - please click on one of the links listed under alternative maps.</noscript>
In the page itself, you need a with the id something like "map", and use style to control the size if you want. I insert the reference to the second blob inside this div.

Hope that helps!
JB4375

Re: Church Website

Post by JB4375 »

MatthewB,

The site looks GREAT! If mine comes off half as nice I'll be pleased.

Nice work,

JB
samb

Re: Church Website

Post by samb »

Very nice looking site.

Could you please pass on the modified code you used to add the week view to the calendar? This seems ideal for what I need for a current project.

Cheers
Sam
matthewb

Re: Church Website

Post by matthewb »

Here are the mods to get week view with Calendar.

I was working with Calendar 0.7 stable, which just has one file, later versions I understand have been broken down into more files. Also, I haven't done it properly with a template tab in the admin panel etc.

First thing is to add the following case to the switch inside function UserDisplay:

Code: Select all

			case 'weeklist':
				$this->DisplayWeekList($id, $parameters, $returnid);
				break;
This is the main DisplayWeekList function. I've left in the code which grabs the external feed information.

Code: Select all

	function DisplayWeekList($id, $parameters, $returnid)
	{
		$category = get_parameter_value($parameters, 'category', '');
		$summaries = get_parameter_value($parameters, 'summaries', 1);
		$detail = get_parameter_value($parameters, 'detail', 0);
		$categories_table_name = $this->categories_table_name;
		$events_to_categories_table_name = $this->events_to_categories_table_name;
		$events_table_name = $this->events_table_name;
		$first_day_of_week = get_parameter_value($parameters, 'first_day_of_week', 1);
		$table_id = get_parameter_value($parameters, 'table_id', 'calendar-'.$id.$returnid);
		$return_link = get_parameter_value($parameters, 'return_link', 0);
		$limit = get_parameter_value($parameters, 'limit', -1);
		$compact_view = get_parameter_value($parameters, 'compact_view', 0);
		$moretext = get_parameter_value($parameters, 'moretext', $this->Lang('cal_more'));

		$reverse = get_parameter_value($parameters, 'reverse', 'false');
		$sorting = ($reverse == 'true' ? 'DESC' : 'ASC');
		

		// basic information about dates
		
		$yesterday=strtotime("-1 day");
		$next_week=strtotime("+1 week");
		$start_month = date('n', $yesterday);
		$start_year = date('Y', $yesterday);
		$start_day = date('d',$yesterday);
		$start = sprintf('%04d-%02d-%02d 00:00:00', date('Y', $yesterday), date('m', $yesterday), date('d', $yesterday));
		$end = sprintf('%04d-%02d-%02d 23:59:59', date('Y', $next_week), date('m', $next_week), date('d', $next_week));
		$first_day = date('w', $yesterday);

		$last_day_of_month = mktime(0, 0, 0, date('m',$next_month), 0, $year);
		$days_in_month=date('d',$last_day_of_month);

		$db = $this->cms->db;
		$where = 'WHERE';
		$sql = "SELECT DISTINCT $events_table_name.*, $categories_table_name.category_name  
				FROM $events_table_name\n";
		// this bit can be left out, but I need the category information in there. NB may cause duplicate entries
                               // if an event has more than one cat.
		$sql .= "LEFT JOIN $events_to_categories_table_name
				   ON $events_table_name.event_id = $events_to_categories_table_name.event_id
				LEFT JOIN $categories_table_name
				   ON $events_to_categories_table_name.category_id = $categories_table_name.category_id
			";
	
	
		$sql .= "$where ($events_table_name.event_date_start >= '$start' \n\tOR $events_table_name.event_date_end >= '$start')\n";
		$sql .= "AND ($events_table_name.event_date_start <= '$end' \n\tOR $events_table_name.event_date_end <= '$end')\n";
		$where = ' AND ';

		if($category)
		{
			$cats = explode(',', $category);
			$sql .= $where . ' (';
			$count = 0;
			foreach($cats as $cat)
			{
				$cat = trim($cat);
				if($count != 0)
				{
					$sql .= ' OR ';
				}
				$count++;
				$sql .= "$categories_table_name.category_name LIKE '$cat' ";
			}
			$sql .=	') ';
			$where = ' AND ';
		}
		$sql .= " ORDER BY $events_table_name.event_date_start $sorting";

		if($limit > 0)
		{
			$rs = $db->SelectLimit($sql, $limit);
		}
		else
		{
		  $rs = $db->Execute($sql); /* @var $rs ADOConnection */
		}



		$days = array();
		$day_names = $this->GetDayNames();

                                // This is the bit that grabs the rss data: can be left out. You need the rss_fetch.inc file.
		require_once 'rss_fetch.inc';

		$rss = fetch_rss('http://www.universalis.com/England/atomweek.xml');
		$item=$rss->items;

		# Usually the Universalis feed begins with yesterday, but it can be the day before.
		# this loop finds the first occurance of yesterday's day name in the feed titles
		# It should never be possible for the first day in the feed to be later than today. If the first day
		# in the feed is today (an exceptional case) then the first occurance of yesterday's day name would be
		# that same day next week, in the 7th entry (array key 6), so by stopping the loop at 5 we ensure that if that is the
		# case the offset is -1 - yesterday in our table will not have universalis data, but every other day will.
		# If yesterday is the first day in the feed, the offset will be 0 (usual case). If yesterday is the second day, the 
		# offset will be 1. Worst case, universalis is broken and the feed begins with tomorrow, then we will end up with an offset of 5
		# and the labels will be a week out, but this should never happen
		$universalis_offset=-1;
		for($j = 0; $j <=5 && $universalis_offset==-1; $j++)
 		{
			if(strncasecmp($item[$j]['title'],$day_names[$first_day],2)==0)
			{
				$universalis_offset=$j;
			}
		}
                            // end of optional RSS-handling section

		for($i = 0; $i <= 7; $i++)
		{
			$dmonth=$start_month;
			$dyear=$start_year;
			$dday=$start_day+$i;
			if($dday>$days_in_month)
			{
				$dday=$dday-$days_in_month;
				$dmonth=$start_month+1;
				if($start_month==12)
				{
					$dyear=$start_year+1;
					$dmonth=1;
				}
			}
			
			$days[$i]['day']=$dday;
			$days[$i]['month']=$dmonth;
			$days[$i]['year']=$dyear;
			if($dday==date('d')||$dday==date('j'))
			{
			$days[$i]['class']="today";
			}
			$day_of_week = ($first_day + $i) % 7;
			$days[$i]['name']=$day_names[$day_of_week];
			$days[$i]['dow']=$day_of_week;
			$days[$i]['url'] = $this->CreateLink($id, 'default', $returnid, $contents='',
				  $params=array('year'=>$dyear, 'month'=>$dmonth, 'day'=>$dday, 'display'=>'list','return_link'=>1,'detail'=>1, 'lang'=>$this->curlang), '', true);
			$days[$i]['events'] = array();

                                              // this bit is just for the rss handling feature
			if($i+$universalis_offset>=0 && $item[$i+$universalis_offset])
			{
				$days[$i]['title'] = $item[$i+$universalis_offset]['summary'];
			}else{
				$days[$i]['title'] = '';
	
			}
		}


		if($rs->RowCount() > 0)
		{
			while($row = $rs->FetchRow())
			{

				//debug_display($row, '$row');
				$start_date = strtotime($row['event_date_start']);

				if(empty($row['event_date_end']))
				{
					$end_date = $start_date;
				}
				else
				{
					$end_date = strtotime($row['event_date_end']);
				}

				$url = $this->CreateLink($id, 'default', $returnid, $contents='', $params=array('year'=>$year, 'month'=>$month, 'event_id'=>$row['event_id'], 'display'=>'event', 'lang'=>$this->curlang), '', true);
				$row['url'] = $url;
				$row['details_nohtml']=strip_tags($row['event_details']);

				for($i=0; $i<=7; $i++)
				{

					if(date('Y',$start_date)==$days[$i]['year'] && date('m',$start_date)==$days[$i]['month'] && date('d',$start_date)==$days[$i]['day'])
					{
						$days[$i]['events'][] = $row;
					}
				}

			}

		}

		$navigation['next'] = $this->CreateReturnLink($id, $returnid, '', array('year'=>$next_month['year'], 'month'=>$next_month['month']), true);
		$navigation['prev'] = $this->CreateReturnLink($id, $returnid, '', array('year'=>$prev_month['year'], 'month'=>$prev_month['month']), true);

		$day_short_names = $this->GetDayShortNames();
		$month_names = $this->GetMonthNames();


		if($first_day_of_week != 0)
		{
			for($i = 0; $i < $first_day_of_week; $i++)
			{
				$first = array_shift($day_names);
				$day_names[] = $first;
				$first = array_shift($day_short_names);
				$day_short_names[] = $first;
			}
		}

		$return_url = '';
		if($return_link == 1)
		{
			$return_url = $this->CreateReturnLink($id, $returnid, $this->lang('cal_return'));
		}

		// other language fields
		$lang = $this->GetLabels();

		// assign to Smarty

		$this->smarty->assign_by_ref('start_month', $start_month);
		$this->smarty->assign_by_ref('month_names', $month_names);
		$this->smarty->assign_by_ref('day_names', $day_names);
		$this->smarty->assign_by_ref('day_short_names', $day_short_names);
		$this->smarty->assign_by_ref('table_id', $table_id);
		$this->smarty->assign_by_ref('days', $days);
		$this->smarty->assign_by_ref('day', $day);
		$this->smarty->assign_by_ref('start_year', $start_year);
		$this->smarty->assign_by_ref('summaries', $summaries);
		$this->smarty->assign_by_ref('detail', $detail);
		$this->smarty->assign_by_ref('return_url', $return_url);
		$this->smarty->assign_by_ref('lang', $lang);
		$this->smarty->assign_by_ref('navigation', $navigation);
		$this->smarty->assign_by_ref('compact_view', $compact_view);

		// Display template
//		if (isset($params['listtemplate']))
//		{
//			echo $this->ProcessTemplate($params['listtemplate']);
//		}
//		else
//		{
//			$t = $this->GetTemplate('weeklist');
//			if(empty($t))
//			{
				$this->SetTemplate('weeklist', $this->GetDefaultTemplate('weeklist'));
//			}

			echo $this->ProcessTemplateFromDatabase('weeklist');
//		}
	}
We also need a template: I just added another case to the switch inside function GetDefaultTemplate. Just to complicate things further I have added a feature that shows weekly service times automatically without needed an event in the database, but they can be cancelled on any given day by adding an event with category 'cancellation'

Code: Select all

			case 'weeklist':
				return '{strip}
<table class="week" id="{$table_id}">
<tbody>
{foreach from=$days item=day}
<tr>
<td valign="top" {if $day.class} class="{$day.class}"{/if}>
{if $day.events.0}<a href="{$day.url}">{$day.name}<br>
{$day.day} {$month_names[$day.month]}</a>
{else}{$day.name}<br>
{$day.day} {$month_names[$day.month]}{/if}
</td>
<td valign="top" {if $day.class} class="{$day.class}"{/if}>
{if $summaries == true}
<span class="universalis">{$day.title}</span>
<ul id="weeklist">
{foreach from=$day.events item=event}
{if $event.event_date_start|date_format:"%H:%M"=="00:00"}<li class="special" style="list-style-image: url(\'uploads/images/day.gif\')"><span title="{$event.details_nohtml}"><a href="{$event.url}"><b>{$event.event_title}</b></a></span> {$event.event_summary}</li>{/if}
{/foreach}
{assign var=no0800service value=0}
{assign var=no0900service value=0}
{assign var=no0930service value=0}
{assign var=no1000service value=0}
{assign var=no1215service value=0}
{assign var=no1830service value=0}
{foreach from=$day.events item=event}
{if $event.category_name=="Cancellation"}
{if $event.event_date_start|date_format:"%H:%M"=="08:00"}{assign var=no0800service value=1}
{elseif $event.event_date_start|date_format:"%H:%M"=="09:00"}{assign var=no0900service value=1}
{elseif $event.event_date_start|date_format:"%H:%M"=="09:30"}{assign var=no0930service value=1}
{elseif $event.event_date_start|date_format:"%H:%M"=="10:00"}{assign var=no1000service value=1}
{elseif $event.event_date_start|date_format:"%H:%M"=="12:15"}{assign var=no1215service value=1}
{elseif $event.event_date_start|date_format:"%H:%M"=="18:30"}{assign var=no1830service value=1}{/if}{/if}
{/foreach}
{if not($day.day==25 && $day.month==12) && not($day.day==26 && $day.month==12)}{if $day.dow==0}{if $no0800service==0}<li class="regular">8.00 Mass*</li>{/if}
{if $no1000service==0}<li class="regular">10.00 Sung Mass*</li>{/if}
{if $no1830service==0}<li class="regular">6.30 Choral Evensong{if $day.day>=1 && $day.day<=7} & Benediction{/if}*</li>{/if}
{elseif $day.dow!=5}
{if $no0900service==0}<li style="list-style-type: none;" class="regular">9.00 Morning Prayer*</li>{/if}
{/if}
{if $day.dow==2}{if $no0930service==0}<li class="regular">9.30 Mass*</li>{/if}{/if}
{if $day.dow==3}{if $no1215service==0}<li class="regular">12.15 Mass*</li>{/if}{/if}
{if $day.dow==6}{if $no0930service==0}<li class="regular">9.30 Mass{if $day.day>=1 && $day.day<=7} (of Requiem){elseif $day.day>=15 && $day.day<=21} (of Healing){/if}*</li>{/if}{/if}{/if}
{foreach from=$day.events item=event}
{if $event.event_date_start|date_format:"%H:%M"!="00:00"}<li class="special" style="list-style-image: url(\'uploads/images/{if $event.event_date_start|date_format:"%H"<13}am.gif{else}pm.gif{/if}\')"><span title="{$event.details_nohtml}"><a href="{$event.url}">{$event.event_date_start|date_format:"%H:%M"}</a></span> <b>{$event.event_title}</b> {$event.event_summary}</li>{/if}
{/foreach}
</ul>
{/if}
</td>
</tr>
{/foreach}
</tbody></table>
{/strip}';
I hope all this is of some use, but there is an awful lot of hard-coded customisation in there which may distract you from the essential stuff (especially in the template section).
Isis

Re: Church Website

Post by Isis »

I have followed your instructions to add the Week View to the Calendar, but it is not working. 

I am running Calendar module version 1.0.

I added the following to the action.default.php file:

case 'weeklist':
require_once(dirname(__FILE__).'/function.displayweeklist.php');
$this->DisplayWeekList($id, $parameters, $returnid);
break;

I created the function.displayweeklist.php file with the code you listed in the instructions, as well as the template.

This is the error I am getting:

Fatal error: Call to undefined method Calendar::DisplayWeekList() in /var/www/htdocs/railyardsantafe.com/modules/Calendar/action.default.php on line 67


Any suggestions?

Thanks,
Isis
Last edited by Isis on Tue Jan 13, 2009 10:42 pm, edited 1 time in total.
Post Reply

Return to “CMS Show Off”