Page 1 of 2

color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Mon Jan 26, 2009 9:30 pm
by JeremyBASS
Ok.. for the calendars it's

{foreach from=$event.categories key=category item=item}{$item.category_name}{/foreach}

for the lists it's

{foreach from=$event.categories key=key item=item}{$key}{/foreach}

so a list sample would be:

{foreach from=$events key=key item=event}

{$event.event_title}
...etc to close {/foreach}

then you just CSS it up and off you go...

cheers
jeremyBass

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 2:13 pm
by benchfrooser
Thx for this.
Is there a way to output the id of the category instead of the name?

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 5:42 pm
by JeremyBASS
Not that I know of with out a custom UDT.  question.. why ? there may be another way to simulate an event id, but it'd be all wall the off stuff... Sorry

cheers
jeremyBass

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 8:05 pm
by benchfrooser
I had Germanic Umlauts (öäü) in my categories, with renaming it I can use the category names.

this code works fine for "upcominglist"

Code: Select all

{foreach from=$event.categories key=key item=item}{$key}{/foreach}
but when I want to use it in "yearlist" I don´t get any categories.

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 8:38 pm
by JeremyBASS
did you try the

{foreach from=$event.categories key=category item=item}{$item.category_name}{/foreach}

??

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 8:44 pm
by benchfrooser
yes, didn´t work, too

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 8:51 pm
by JeremyBASS
well.. what is "yearlist"?  what it the template and it's code..?

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sun Feb 22, 2009 9:17 pm
by benchfrooser

Code: Select all

<table>
<caption>Termine:</caption>
<thead>
<tr>
<th colspan="2">Datum</th>
<th>Uhrzeit</th>
<th>Betreff</th>
</tr>
</thead>
<tbody>
{foreach from=$events key=key item=event}
{assign var=month_number value=$event.event_date_start|date_format:"%m"}
<tr class="{foreach from=$event.categories key=key item=item}{$key}{/foreach}">
<td>{$event.event_date_start|date_format:"%d."} {$month_names[$month_number]}</td> 
<td>{$event.event_date_start|date_format:"%a"}</td>
<td>{$event.event_date_start|date_format:"%H:%M"}</td> 
<td>{$event.event_title}</td>
</tr>
{/foreach}
</tbody>
</table>
This Template works in Upcoming-Template, but not in List-Template.
I use Calendar Version 1.0
{cms_module module='Calendar' display='yearlist'} Makes a list of the events in this year and use the template in the List-Tap.

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sat Mar 14, 2009 12:58 am
by hexdj
Thanks Jeremy!  :D

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Sat Mar 14, 2009 4:07 am
by JeremyBASS
@ hexdj
handy is it not?... sorry it was award night nigt, I won alot, yeah me lol.... and it was a bet tro drink a shoot for every gold... off to the internationals.. hehe...


ok that was not that relatvented but three of the gold awards were for CMSMS sites I mmade... :)

CDheers, one more round to everyone, ted to calgay to alby to ronnyk _sgi_.. ecft...


ok... I'm out... GO CMSMS
jeremy

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Wed Sep 23, 2009 7:11 pm
by deejmer
I really need this functionality, but cannot figure out how to get it to work.

Using CMSMS 1.6.5, and CGcalendar 1.2.3

I have a Calendar template, which is the default.  I simply want to add the class, or ID, or array index of the Category in the template to control styling.

Code: Select all

{strip}
<table class="calendar" id="cal-calendar">
<caption class="calendar-month"><span class="calendar-prev"><a href="{$navigation.prev}">«</a></span> {$month_names[$month]} {$year} <span class="calendar-next"><a href="{$navigation.next}">»</a></span></caption>
<tbody><tr>
{foreach from=$day_names item=day key=key}
<th abbr="{$day}">{$day_short_names[$key]}</th>
{/foreach}</tr>

<tr>
{* initial empty days *}
{if $first_of_month_weekday_number > 0}
<td colspan="{$first_of_month_weekday_number}"> </td>
{/if}

{* iterate over the days of this month *}
{assign var=weekday value=$first_of_month_weekday_number}
{foreach from=$days item=day key=key}
{if $weekday == 7}
	{assign var=weekday value=0}
</tr>
<tr>
{/if}
<td {if isset($day.class)}class="{$day.class}"{/if}>
{if isset($day.events.0)}<a href="{$day.url}">{$key}</a>
<ul>
{foreach from=$day.events item=event}
<!-- HERE IS WHERE I ADDED THE TAG --> <div class="calendar-event  {foreach from=$event.categories key=key item=item}{$key}{/foreach}">
<li><a href="{$event.url}">{$event.event_title}</a></li>
<!-- CLOSING DIV TAG  FOR ABOVE ADDED ELEMENT--></div>
{/foreach}
</ul>
{else}{$key}{/if}
</td>
{math assign=weekday equation="x + 1" x=$weekday}
{/foreach}

{* remaining empty days *}
{if $weekday != 7}
<td colspan="{math equation="7-x" x=$weekday}"> </td>
{/if}


</tr>
</tbody></table>

{/strip}

When I look at the output in Firefox (firebug) it shows the class as "calendar-event0" no matter which category its in.  I cannot get a value other than this.  Can you tell me what I'm doing wrong?

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Wed Sep 23, 2009 8:00 pm
by JeremyBASS
so really it's like this...


{foreach from=$event.categories key=key item=item}{$key}{/foreach}

or

{foreach from=$event.categories key=category item=item}{$item.category_name}{/foreach}

those will out put the cats... so then you stick it in where you wish like this example...

class="calendar-event  {foreach from=$event.categories key=key item=item}{$key}{/foreach}"

you may be able to do
{$event.categories->category_name}
but I have not tested...



Hope this helps...

Cheers
Jeremy


note... try 


Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Wed Sep 23, 2009 8:21 pm
by deejmer
Thanks so much Jeremy...this is what worked in the template for me:

{$event.event_title}

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Wed Sep 23, 2009 9:12 pm
by JeremyBASS
Np... helping is good karma for the soul :D

Re: color coding you calendar events... (CGCalendar/Calendar1.0)

Posted: Wed Jan 13, 2010 6:25 pm
by Peciura
CGCalendar 1.2.5
This template and CSS sets color according category of the event. If event belongs to multiple categories, depending on CSS, day can have combination of category markings or day can be marked with "multiple category" pattern ( uncomment class "cgcalendar_multiple_category").

Image Image

Template

Code: Select all

{strip}
	<table class="calendar" id="cal-calendar">
		<caption class="calendar-month">
			<span class="calendar-prev">
				<a href="{$navigation.prev}">
					«
				 </a>
				  
			</span> 
			{$month_names[$month]} {$year} 
			<span class="calendar-next">
				 
				<a href="{$navigation.next}">
					 »
				</a>
			</span>
		</caption>
		<tbody>
			<tr>
				{foreach from=$day_names item=day key=key}
					<th abbr="{$day}">
						{$day_short_names[$key]}
					</th>
				{/foreach}
			</tr>				
			<tr>
				{* initial empty days *}
				{if $first_of_month_weekday_number > 0}
					<td colspan="{$first_of_month_weekday_number}"> </td>
				{/if}
				
				{* iterate over the days of this month *}
				{assign var=weekday value=$first_of_month_weekday_number}
				{foreach from=$days item=day key=key}
					{if $weekday == 7}
						{assign var=weekday value=0}
						</tr>
						<tr>
					{/if}
					<td >
						<div class='cgcalendar_day' id='cgcalendar_day_{$key}'> 
							{if isset($day.class)}
								<div class="{$day.class}">
							{/if}
							{if isset($day.events.0)}					
								{assign var='cgcalendar_multiple_category' value=''}
								{assign var='first_category' value=''}
								{foreach from=$day.events item=event}
									{foreach from=$event.categories item=category}
										<div class="cgcalendar_category_{$category.category_id} cgcalendar_category
											{if $first_category==''}
												{assign var='first_category' value=`$category.category_id`}
											{elseif $first_category!=$category.category_id}
												{assign var='cgcalendar_multiple_category' value=`$category.category_id`}
											{/if}					
										"> 
									{/foreach}
								 {/foreach} 
					
								{if !empty($cgcalendar_multiple_category)}
									<div class='cgcalendar_multiple_category'>
								{/if}
								
								<a href="{$day.url}">{$key}</a>
								
								{if !empty($cgcalendar_multiple_category)}
									</div>
								{/if}
								
								{foreach from=$day.events item=event}
									{foreach from=$event.categories item=category}
										</div>  
									{/foreach} 
								{/foreach} 
								
								<div class='cgcalendar_info'>
									<ul style='float:left;'>
										{foreach from=$day.events item=event}
											<li>
												<a href="{$event.url}">
													{$event.event_title}
												</a>
											</li>
										{/foreach}
									</ul>
								</div>
							</div> 
							{else}
								{$key}
							{/if}
						
							{if isset($day.class)}
								</div>
							{/if}			
						</div> 
					</td>
					{math assign=weekday equation="x + 1" x=$weekday}
				{/foreach}
			
				{* remaining empty days *}
				{if $weekday != 7}
					<td colspan="{math equation="7-x" x=$weekday}"> </td>
				{/if}			
			</tr>
		</tbody>
	</table>

{/strip}
Basic CSS for CGCalendar.

Code: Select all

/* CGCalendar*/

div.cgcalendar_day{
	position: relative;
	text-align:right;
}
.cgcalendar_category, .cgcalendar_day, .cgcalendar_multiple_category {
	width:21px;
	min-width:21px;
	height:21px;
	min-height:21px;
}

div.cgcalendar_day div.cgcalendar_info{
	display:none;
	z-index:2;
	position: absolute;
	bottom:1.3em;
	left:0px;
	background-color:#ffffff;
	border: solid 1px #CEDE95;
}
#cal-calendar div.cgcalendar_info ul{
	padding:0px;
	margin:  1em 2em;
	text-align:left;
}
div.cgcalendar_day:hover div.cgcalendar_info, div.cgcalendar_day div.cgcalendar_info :hover{
	display:block;
}

/*.cgcalendar_multiple_category{
	background-color:#ECEBE6;
}*/


.cgcalendar_category_1, .cgcalendar_category_2, .cgcalendar_category_3, .cgcalendar_category_4{
	background-image:url('images/cgcalendar_category.png');
	background-repeat:no-repeat;
	background-color:transparent;
}
.cgcalendar_category_1{
	background-position:-11px -11px;
}
.cgcalendar_category_2{
	background-position:11px -11px;
} 
.cgcalendar_category_3{
	background-position:-11px 11px;
} 
.cgcalendar_category_4{
	background-position:11px 11px;
}

table#cal-calendar .calendar-today{
	border:1px solid #ff0000;
	z-index:1;
	text-align:center;
}