[SOLVED] Help: Need 2 CGCalendars on one page

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

[SOLVED] Help: Need 2 CGCalendars on one page

Post by inyerface »

Hello,

I have two CGCalendar's on one page... they work great if I sett hem to inline but I have a problem:

1) If inline, I hit next on one and I can go through the months but as soon as I hit next on the other one, the first one is reset to "today".

2) What I'd really like is to have both calendars displayed but when you hit next, both calendars change to the ame month. How can this be done?

http://66.48.72.81/~ruecater/index.php? ... ailability

The smarty code I use is:

Code: Select all

{cms_module module="CGCalendar" display="calendar" detailpage="calendar" calendartemplate="Calendar" category="No5"}

{cms_module module="CGCalendar" display="calendar" detailpage="calendar" calendartemplate="Calendar" category="No7"}
I love this module and wouldn't want to mofify it. Any help is appreciated.

Note: This is really just to show availability on two different properties that are next door to each other.

Thanks!!
Last edited by inyerface on Fri Sep 20, 2013 3:21 am, edited 1 time in total.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Help: Need 2 CGCalendars on one page

Post by Rolf »

You can put the content of two different templates in one new template, working example:
http://www.zeijen.nu/agenda
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: Help: Need 2 CGCalendars on one page

Post by inyerface »

But can I display two calendars displaying different categories?
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: Help: Need 2 CGCalendars on one page

Post by inyerface »

Thanks Rolf.

I got the calendars changing together but how would I show the events from one category in the first one and the events in another category in the other?

My working example:

http://66.48.72.81/~ruecater/index.php?page=test
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Help: Need 2 CGCalendars on one page

Post by calguy1000 »

I would start looking at the use_session parameter. However, that may cause it's own complications.

If that doesn't work, then you'll prolly need some customizations.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: Help: Need 2 CGCalendars on one page

Post by inyerface »

So close... thought I had a workaround.

I decided to hard code the colors in the template using {$event.categories.0.category_name} and {if} statements but noticed that when there are overlapping events, only one category is listed on that day when there should really be both.

<pre>{$event.categories.0|@print_r}</pre>

How can his be fixed to show the two category names associated with that day?
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: Help: Need 2 CGCalendars on one page

Post by inyerface »

So this is what I did:

http://66.48.72.81/~ruecater/index.php?page=test

I have two categories for each property... N05 and No7

I altered the table where the <td> colors are managed based on whether there's an event:

<td valign="top" align="right" {if isset($day.class)}class="{$day.class}"{/if}{foreach from=$day.events item=event}{if $event.categories.0.category_name == "No5"}style="background-color: #a0c084;"{else}style="background-color: #444;color:#f0f0f0;"{/if}{/foreach} style="background-color:#a0c084;">

So I'm essentially saying to ignore No7 category on the calendar... it works great UNTIL there's an overlapping event.

The other thing I though of doing was counting the number of events that appear:

{foreach from=$day.events item=event}
{$event.event_title}
{/foreach}

How can I count how many {$event.event_title} there are per day? That'll resolve my issue
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Help: Need 2 CGCalendars on one page

Post by calguy1000 »

try: {$nevents=count($day.events)}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: Help: Need 2 CGCalendars on one page

Post by inyerface »

Thank you Calguy!!

For those who can understand my logic here's my hack. Note, the two categories I have are No5 and No7:

<td valign="top" align="right" {if isset($day.class)}class="{$day.class}"{/if}{foreach from=$day.events item=event}{if count($day.events) == "2" || $event.categories.0.category_name == "No5"} style="background-color: #444;color:#f0f0f0;"{else} style="background-color:#a0c084;"{/if}{/foreach} style="background-color:#a0c084;">

The logic:

If there are 2 events in that day OR the event is tied to the category I mentioned, then run the style proposed, else just make the background the defaul color.

Works like magic. Thanks for the tip Calguy!!

The full Calendar Display template:

Code: Select all


{strip}
<div class="nextprev">
  <span class="calendar-prev"><a href="{$navigation.prev}"><img src="uploads/images/bg/arrow-left.png" alt="" /></a></span> 
  <span class="calendar-month">{$month_names[$month]} {$year} </span>
  <span class="calendar-next"><a href="{$navigation.next}"><img src="uploads/images/bg/arrow-right.png" alt="" /></a></span>
</div>


<table class="calendar-big" id="cal-calendar" cellpadding="0" cellspacing="2">
<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 valign="top" align="right" {if isset($day.class)}class="{$day.class}"{/if}{foreach from=$day.events item=event}{if count($day.events) == "2" || $event.categories.0.category_name == "No5"} style="background-color: #444;color:#f0f0f0;"{else} style="background-color:#a0c084;"{/if}{/foreach} style="background-color:#a0c084;">
{if isset($day.events.0)}{$key}


{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}


<br />
<br />

{strip}

<table class="calendar-big" id="cal-calendar" cellpadding="0" cellspacing="2">
<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 valign="top" align="right" {if isset($day.class)}class="{$day.class}"{/if}{foreach from=$day.events item=event}{if count($day.events) == "2" || $event.categories.0.category_name == "No7"} style="background-color: #444;color:#f0f0f0;"{else} style="background-color:#a0c084;"{/if}{/foreach} style="background-color:#a0c084;">
{if isset($day.events.0)}{$key}

{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}

Last edited by inyerface on Sat Sep 21, 2013 8:28 pm, edited 2 times in total.
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: Help: Need 2 CGCalendars on one page

Post by inyerface »

calguy1000 wrote:try: {$nevents=count($day.events)}
{count($day.events)} DID THE TRICK :)))
inyerface
Forum Members
Forum Members
Posts: 191
Joined: Mon Nov 26, 2007 4:46 pm

Re: [SOLVED] Help: Need 2 CGCalendars on one page

Post by inyerface »

I'm more than thrilled about this!!! Using only 1 instance of CGCalendar and we can add more than one with both categories (properties) displaying avialability.

http://66.48.72.81/~ruecater/index.php? ... ailability
Post Reply

Return to “Modules/Add-Ons”