how to show cgcalendar categories??

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Peciura

Re: how to show cgcalendar categories??

Post by Peciura »

Just extended Beattie's template.
Now list template name and event template name is saved to variables. If event template is not passed as parameter default template is used. Hopefully there are no bugs left... :)

{assign var='private_events' value='|'|explode:'Wedding|Baptism|Funeral'} {* category list of private event *}
{assign var='label_private_event' value='(private event, by invitation only)'} {* private event label *}
{assign var='cgcal_list_template_name' value=$smarty.template|replace:'module_db_tpl:CGCalendar;list_':''} {* save current template name to variable *}
{assign var='cgcal_event_template_name' value=$actionparams.eventtemplate|default:$CGCalendar->GetPreference($smarty.const.CGCALENDAR_PREF_DFLTEVENT_TEMPLATE)} {* get event template or use default one *}

{if $day > 0}{$day} {/if}{$month_names[$month]} {$year}

{if isset($navigation)}
{capture assign='cgcal_nav_tail'}{'&amp'};{$actionid}listtemplate={$cgcal_list_template_name}{/capture} {* save list template name to append navigation links *}
{* save navigation and repeat it at the bottom *}
{capture assign='cgcalendar_nav'}


{if isset($navigation.prev)}{$lang.prev}
{/if}

{* month navigation *}


{section name='month_navigation' start='1' loop='13'}
{assign var='month_name_short' value='2010-%s-01 00:00:00'|sprintf:$smarty.section.month_navigation.iteration|date_format:'%b'}
{if $month!=$smarty.section.month_navigation.iteration}
{$month_name_short}
{else}
{$month_name_short}
{/if}
{if !$smarty.section.month_navigation.last} | {/if}
{/section}


{* end month navigation *}

{if isset($navigation.next)}{$lang.next}

{/if}

{/capture}
{* end save navigation and repeat it at the bottom *}
{$cgcalendar_nav}
{/if}


{if !empty($events)}
{foreach from=$events key=key item=event}


{$event.event_title}
{assign var=month_number value=$event.event_date_start|date_format:"%m"}
{assign var=end_month_number value=$event.event_date_end|date_format:"%m"}

{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
{$lang.date}: {$event.event_date_start|date_format:"%a %e %b %G"}
Time: {$event.event_date_start|date_format:"%I:%M%P"}

{else}

{if $event.event_date_start|date_format:"%a %e %b %G" == $event.event_date_end|date_format:"%a %e %b %G"}
{$lang.date}: {$event.event_date_start|date_format:"%a %e %b %G"}    Time: {$event.event_date_start|date_format:"%I:%M%P"} - {$event.event_date_end|date_format:"%I:%M%P"}

{else}
{$lang.date}:
{if $event.event_date_start|date_format:"%a %e %b %G"} to {$event.event_date_end|date_format:"%a %e %b %G"}  Time: {$event.event_date_start|date_format:"%I:%M%P"} {$lang.to} {$event.event_date_end|date_format:"%I:%M%P"}  
{/if}
{/if}
{/if}

{* event categories *}
{if !empty($event.categories)}
{assign var='private_event' value=''}
{assign var='event_categories' value=$event.categories|@array_keys}
{$CGCalendar->Lang('category')}: {', '|implode:$event_categories}
{foreach from=$event_categories item='cat_name'}
{if in_array($cat_name, $private_events)}
{assign var='private_event' value='1'}
{/if}
{/foreach}
{if !empty($private_event)} {$label_private_event}
{/if}
{/if}
{* end event categories *}



{if $event.event_summary !="" && ($detail != 1 || ($event.event_details =="" ||  $event.event_details == "
"))}
{$event.event_summary}
{/if}
{* optionally display detail information
{if $event.event_details !="" && $event.event_details != "
"}
{$lang.details}: {$event.event_details}
{/if}
*}

more details  »




{/foreach}
{else}


There are currently no events.


{/if}


{* navigation once more :) *}
{if isset($navigation)}
{$cgcalendar_nav}
{/if}








{if $return_url != ""}
{$return_url}
{/if}
Attachments
beaties_cgcalendar.png
Last edited by Peciura on Tue Nov 09, 2010 11:02 pm, edited 1 time in total.
ataxel
Forum Members
Forum Members
Posts: 41
Joined: Thu Jul 19, 2007 1:32 pm

Re: how to show cgcalendar categories??

Post by ataxel »

I use this setting on a site and the only thing still confusing is the LANG parameters.
I have a french site and change my locale to fr_FR that gave me le month list in french but keep the month title in english, also, it display a � character instead of the É.

Also, when i change the locale in the CGcalendar tag, everything stays in english.
Can you help please

Thank you

LP(*
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

Re: how to show cgcalendar categories??

Post by beattie »

Hi ataxel, can you post your template and the code you are using to call the calendar list, also a link to the page if possible. Are you using the MLE version of CMS? Peciura is much more likely to be able to help you out but if you post more details, it might speed things along for you  :)
ataxel
Forum Members
Forum Members
Posts: 41
Joined: Thu Jul 19, 2007 1:32 pm

Re: how to show cgcalendar categories??

Post by ataxel »

Thank you to offer me your help. I use CMSMS 1.9.2 and CgCalendar 1.5.6. No more MLE for me since is not support...
For the calendar I basically take the code as it is. The styling and modifications will come later.

Code: Select all

<div>

<h2 style="text-align:center; text-transform:uppercase;font-size:20px;color:; padding:10px 0;">{if $day > 0}{$day} {/if}{$month_names[$month]} {$year}</h2>

		{if isset($navigation)}
			{capture assign='cgcal_nav_tail'}{'&amp'};{$actionid}listtemplate={$smarty.template|replace:'module_db_tpl:CGCalendar;list_':''}{/capture}
			{capture assign='cgcalendar_nav'}
			<div style="border-bottom: 2px solid rgb(240, 240, 240); padding: 0pt 8px 8px; position: relative; margin-top: 8px;">

			{if isset($navigation.prev)}<a style="font-size: 11px;  float: left; text-decoration: none; text-transform:uppercase; display: block; position: absolute; left: 0pt; top: 0pt;" href="{$navigation.prev}{$cgcal_nav_tail}">Précédent</a>
			{/if}

			{* month navigation *}
			<div style="display: block; margin: auto; width: 85%; text-align: center;">
				<span style="color: #e11831;font-size:11px;text-transform:uppercase;">
				{section name='month_navigation' start='1' loop='13'}
					{assign var='month_name_short' value='2010-%s-01 00:00:00'|sprintf:$smarty.section.month_navigation.iteration|date_format:'%b'}
					{if $month!=$smarty.section.month_navigation.iteration}
						<a style="color:#60553d;text-decoration:none" href="{module_action_link module='CGCalendar'  urlonly='1' year=$year month=$smarty.section.month_navigation.iteration display='list' eventtemplate='event'  listtemplate='list' use_session='1' lang=fr_FR}
							">{$month_name_short}</a>
					{else}
						{$month_name_short}
					{/if}
					{if !$smarty.section.month_navigation.last} | {/if}
					{/section}
				</span>
			</div>
			{* end month navigation *}

			{if isset($navigation.next)}<a style="color: rgb(104, 94, 71); font-size: 11px; text-transform: uppercase; padding-top: 0px; margin-top: 0px; text-decoration: none; display: block; position: absolute; right: 0pt; top: 0pt;"  href="{$navigation.next}{$cgcal_nav_tail}">Suivant</a>
			</span>
			{/if}
			</div>
			{/capture}
			{$cgcalendar_nav}
	{/if}

		<p style="padding-top:20px"> </p>
		{if !empty($events)}
			{foreach from=$events key=key item=event}
				<div>

					<h2><a style="color: #a6b483;font-size:36px;text-decoration:none" href="{$event.url}">{$event.event_title}</a></h2>
					{assign var=month_number value=$event.event_date_start|date_format:"%m"}
					{assign var=end_month_number value=$event.event_date_end|date_format:"%m"}

					{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
						<span style="color:#666633;font-weight:bold">{$lang.date}:</span> {$event.event_date_start|date_format:"%a %e %b %G"}<br/>
						<span style="color:#666633;font-weight:bold">Heures:</span> {$event.event_date_start|date_format:"%I:%M%P"}<br/>

					{else}

						{if $event.event_date_start|date_format:"%a %e %b %G" == $event.event_date_end|date_format:"%a %e %b %G"}
							<span style="color:#666633;font-weight:bold">{$lang.date}: </span>{$event.event_date_start|date_format:"%a %e %b %G"}  <br>  <span style="color:#666633;font-weight:bold">Heure:</span> {$event.event_date_start|date_format:"%I:%M%P"} - {$event.event_date_end|date_format:"%I:%M%P"}<br/>

						{else}
							<span style="color:#666633;font-weight:bold">{$lang.date}:</span>
							{if $event.event_date_start|date_format:"%a %e %b %G"} to {$event.event_date_end|date_format:"%a %e %b %G"}<br>  <span style="color:#666633;font-weight:bold">Heure:</span> {$event.event_date_start|date_format:"%I:%M%P"} {$lang.to} {$event.event_date_end|date_format:"%I:%M%P"}  <br/>
							{/if}
						{/if}
					{/if}
					{* event categories *}
					{if !empty($event.categories)}
						{assign var='event_categories' value=$event.categories|@array_keys}
						<span style="color:#666633;font-weight:bold">Catégorie:</span> {', '|implode:$event_categories}
						{foreach from=$event_categories item='cat_name'}

						{/foreach}
						
					{/if}
					{* end event categories *}



				{if $event.event_summary !="" && ($detail != 1 || ($event.event_details =="" ||  $event.event_details == "<br />"))}
					<div class="description" style="padding-top:10px">{$event.event_summary}</div>
				{/if}
				
				<p style="margin-top:12px">
				<a style="text-decoration:none;color:#98a677" href="{$event.url}">plus d'informations  »</a></p>

				</div>

				<div style="border-bottom: 1px dashed #e11831;padding-bottom:10px;margin:20px 0;"> </div>
			{/foreach}
		{else}

			<div style="border-top: 1px dashed #e11831;padding-bottom:7px;margin-top:17px"> </div>
			<p><em>There are currently no events.</em></p>

			<div style="border-bottom: 1px dashed #e11831;padding-bottom:7px;"> </div>
		{/if}

		<div>

			{if isset($navigation)}
				{$cgcalendar_nav}
			{/if}

		</div>

		<P></p>
		<P></p>



		{if $return_url != ""}
			<div class="calendar-returnlink" style="clear:both;padding-top:25px">{$return_url}</div>
		{/if}
	</div>

{*get_template_vars}
{$lang|debug_display*}


The page where you can find the calendar is http://www.janiclosier.com/v4/index.php/calendrier.html

Happy new year!
Louis-Philippe (*
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

Re: how to show cgcalendar categories??

Post by beattie »

Have you added lang=fr_FR to your CGCalendar call? for example on the calendar page does it have something like this?

{cms_module module="CGCalendar" display="list" listtemplate="list" inline="1" eventtemplate="event" lang=fr_FR}

Regarding the problem with the French accents, this post might solve your problem:

http://forum.cmsmadesimple.org/viewtopi ... ccent#p921
ataxel
Forum Members
Forum Members
Posts: 41
Joined: Thu Jul 19, 2007 1:32 pm

Re: how to show cgcalendar categories??

Post by ataxel »

I did wrote the lang=fr_FR,
i'm try the other solution you send me, but since i'm working with UTF-8 till the beginning, it changes every other accent to strange character but solve the calendar problem.

As i know where to check, i'll try to resolve it. I'll look for a tag that locally change the encoding ...
Your help was precious!

Thank you
beattie
Forum Members
Forum Members
Posts: 98
Joined: Sun Dec 21, 2008 11:35 pm

Re: how to show cgcalendar categories??

Post by beattie »

No problem :)

Just a suggestion: maybe you can create a template just for the calendar and make the utf change etc in the template so that it doesn't affect the whole site.
User avatar
Nettie
Forum Members
Forum Members
Posts: 53
Joined: Tue Oct 03, 2006 11:42 pm

Re: how to show cgcalendar categories??

Post by Nettie »

I have used the above list - works great :)

I am wondering how you can add the category to the calendar itself? I have tried to copy and paste the code, but can't get it to work. I have the subject and details showing when i hover a date in the calendar, but I would like it to show the category too as I have to use it as a booking calendar for meetingrooms.

My calendar template looks like this:

Code: Select all

{strip}
<table class="calendar1" id="cal-calendar1">
   <caption class="calendar-month1">
      <span class="calendar-prev1">
         <a href="{$navigation.prev}">«   </a>
      </span>
 {$month_names[$month]} {$year} 
      <span class="calendar-next1">
         <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}
         
            {if isset($day.events.0)}
              <td class="cgcalendar_event1"{if isset($day.class)}id="calendar-today1"{/if}>
              <div class="cgcalendar_content1">
              <a href="{$day.url|replace:$actionid:'cntnt01'}">{$key}</a>
              <div class='cgcalendar_info1'>
                <ul>
                 {foreach from=$day.events item=event}
                 <li><a href="{$event.url}"><div class="eventoverskrift">{$event.event_title}</div><br />{$event.event_summary}<br /></a></li>
                 {/foreach}
                </ul>
              </div>
         {else}
              <td class="cgcalendar_day1" {if isset($day.class)}id="calendar-today1"{/if}>
              <div class="cgcalendar_content1">
               {$key}
            {/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}
Hope somebody can help me as I don't know much about smarty - yet :)

Thank you in advance.
henris17
Forum Members
Forum Members
Posts: 70
Joined: Sun Feb 06, 2011 11:11 pm

Re: how to show cgcalendar categories??

Post by henris17 »

Nice solution. But wouyld someone know how to translate in another language the dates in the list template, as welle as the short month of the navigation in the same template.

Many Thanks

Henris
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: how to show cgcalendar categories??

Post by manuel »

Maybe this can help?
http://www.i-do-this.com/blog/34/Localize-your-dates

Greetings,
Manuel
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: how to show cgcalendar categories??

Post by manuel »

ps: in most cases the character encoding works fine when localizing your dates but in some cases i'm experiencing some issues...

cfr: http://forum.cmsmadesimple.org/viewtopi ... =8&t=51617

Greetings,
Manuel
henris17
Forum Members
Forum Members
Posts: 70
Joined: Sun Feb 06, 2011 11:11 pm

Re: how to show cgcalendar categories??

Post by henris17 »

Thanks Manuel,

I tried {time_locale_fr} at the beginning of the template for CGCalemdar (list) and got an error message saying:

string(147) "Smarty error: [in module_db_tpl:CGCalendar;list_list line 1]: syntax error: unrecognized tag 'time_locale_fr' (Smarty_Compiler.class.php, line 590)".

I entered the calendar with lang=fr_FR as parameter.

Here is my problem

Title date (H3) is translated in french (= OK) the other dates are not. Here is part of my template (as described on this post).
<div>

<h3 style="text-align:center; text-transform:uppercase;color:; padding:10px 0;">{if $day > 0}{$day} {/if}{$month_names[$month]} {$year}</h3>

{if isset($navigation)}
{capture assign='cgcal_nav_tail'}{'&amp'};{$actionid}listtemplate={$smarty.template|replace:'module_db_tpl:CGCalendar;list_':''}{/capture}
{capture assign='cgcalendar_nav'}
<div style="border-bottom: 2px solid rgb(240, 240, 240); padding: 0pt 8px 8px; position: relative; margin-top: 8px;">

{if isset($navigation.prev)}<a style="font-size: 11px; float: left; text-decoration: none; text-transform:uppercase; display: block; position: absolute; left: 0pt; top: 0pt;" href="{$navigation.prev}{$cgcal_nav_tail}">Précédent</a>
{/if}

{* month navigation *}
<div style="display: block; margin: auto; width: 85%; text-align: center;">
<span style="color: #e11831;font-size:11px;text-transform:uppercase;">
{section name='month_navigation' start='1' loop='13'}
{assign var='month_name_short' value='2010-%s-01 00:00:00'|sprintf:$smarty.section.month_navigation.iteration|date_format:'%b'}
{if $month!=$smarty.section.month_navigation.iteration}
<a style="color:#60553d;text-decoration:none" href="{module_action_link module='CGCalendar' urlonly='1' year=$year month=$smarty.section.month_navigation.iteration display='list' eventtemplate='event' listtemplate='list' use_session='1' }
">{$month_name_short}</a>
{else}
{$month_name_short}
{/if}
{if !$smarty.section.month_navigation.last} | {/if}
{/section}
</span>
</div>
{* end month navigation *}
User avatar
manuel
Power Poster
Power Poster
Posts: 354
Joined: Fri Nov 30, 2007 9:15 am

Re: how to show cgcalendar categories??

Post by manuel »

Did you create the UDT's?
Quote from article:
"First, create a new UDT for every language you wish to support."
To be able to use {time_locale_fr} in your template you first need to create a UDT called time_locale_fr...
The content of the UDT:

Code: Select all

setlocale (LC_TIME, 'fr_FR.UTF8');
henris17
Forum Members
Forum Members
Posts: 70
Joined: Sun Feb 06, 2011 11:11 pm

Re: how to show cgcalendar categories??

Post by henris17 »

Many thanks Manuel , this solve the problem. I overlooked the UDT (Gods know why), but now It's working.

Cheers

Henri
User avatar
thomahawk
Power Poster
Power Poster
Posts: 312
Joined: Fri Jul 25, 2008 10:13 am

Re: how to show cgcalendar categories??

Post by thomahawk »

I am also trying to achieve a simple display of the category. But it does not work:

{foreach from=$events key=key item=event}
<td valign="top">
{$event.event_categories item='cat_name'}
</td>
{/foreach}

What did I wrong here, can someone help?
Post Reply

Return to “Modules/Add-Ons”