CGCalendar: Swtich between Calendar view and List view?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

CGCalendar: Swtich between Calendar view and List view?

Post by cpansewicz »

This is probably something very simple. I am not very clear on how to do this though. I have my calendar in Calendar view on one page. And I would like have navigation to switch it to List view.

What I have done is to create a second page with the Calendar in list view, and linked to that page. Is this the correct way to do this, or is there another way to do this?

Thank you.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar: Swtich between Calendar view and List view?

Post by velden »

You can use an extra parameter in the url and use that inside the template/content.

But please test if it works well when visitors click on an calendar event and back etc.

Incomplete example:

Code: Select all

...
{if $smarty.get.view == 'list'}{$calendarview='list'}{else}{$calendarview='calendar'}{/if}
{CGCalendar ... view=$calendarview ...}
....

{if $calendarview=='list'}
  {cms_selflink page=$page_alias text='Switch to Calendar view'}
{else}
  {cms_selflink page=$page_alias urlparam='view=list' text='Switch to List view'}
{/if}
...
Perhaps you should work with cookies to remember the choice of the visitor. http://www.cmscanbesimple.org/blog/set- ... ug-cookies
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Swtich between Calendar view and List view?

Post by cpansewicz »

Thank you for that suggestion. I implemented the code below. When I click on "Switch to List View" I receive the error:

"Not Found
The requested URL /events-list-view-test.htmlview=list was not found on this server."

Also, does this set-up require having two separate pages, one for the calendar, and one for the list?

Thank you for your help.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar: Swtich between Calendar view and List view?

Post by velden »

{cms_selflink page=$page_alias urlparam='?view=list' text='Switch to List view'}
It would require one page
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Swtich between Calendar view and List view?

Post by cpansewicz »

Hi, sorry for the delay. The menu portion of this works great. But when I click to switch between List and Calendar views, the calendar portion doesn't change.

I tried changing 'view' to 'display', since view is not a parameter in CGCalendars. (maybe that doesn't have anything to do with it). That didn't work.

On my calendar page I have the code:
{if $smarty.get.view == 'list'}{$calendarview='list'}{else}{$calendarview='calendar'}{/if}
{cms_module module="CGCalendar" view=$calendarview calendartemplate='calendarview2' listtemplate='listview2' category="Calendar of Events" inline="1"}

I'm not savvy enough with Smarty to figure this out. Thank you for your assistance.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar: Swtich between Calendar view and List view?

Post by velden »

This works for me:

Code: Select all

{if $smarty.get.view == 'list'}{$calendarview='list'}{else}{$calendarview='calendar'}{/if}
<div>
{cms_module module="CGCalendar" display=$calendarview inline=1}</div>
<div>{if $calendarview=='list'}
  {cms_selflink page=$page_alias text='Switch to Calendar view'}
{else}
  {cms_selflink page=$page_alias urlparam='?view=list' text='Switch to List view'}
{/if}</div>
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

SOLVED: CGCalendar: Swtich between Calendar view and List vi

Post by cpansewicz »

Yes! Thank you. When I was testing the difference between "view" and "display", I was changing all instances of "view", instead of leaving "view" in the smarty, and adding "display" to the Calendar code.

Thank you again. This really simplifies my life.
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Swtich between Calendar view and List view?

Post by cpansewicz »

How I could add a third navigation item that would call in a different calendar based on category?
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

Re: CGCalendar: Switch between Calendar view and List view?

Post by cpansewicz »

Sorry to reopen this. I have implemented the code you have helped me with, and the calendar does switch between calendar view and list view.

The issue I am having now is that the prev/next navigation in list view does not function. They just switch me back to the calendar view. The prev/next navigation works fine in Calendar View.

The code on my calendar page is:
{if $smarty.get.view == 'list'}{$calendarview='list'}{else}{$calendarview='calendar'}{/if}
<div class="cal-calendar">
{cms_module module="CGCalendar" display=$calendarview calendartemplate='calendarview2' listtemplate='listview2' category="Calendar of Events" inline="1"}
</div>

Then in my list template, the code is:
<div class="change-view">
<h4>Calendar View:
{if $calendarview=='calendar'}
{cms_selflink page=$page_alias text='Switch to List view'}
{else}
{cms_selflink page=$page_alias urlparam='?view=calendar' text='Switch to Calendar view'}
{/if}
</h4>
</div>

<div>
{if isset($navigation)}
{if isset($navigation.prev)}
<div id="prev-next"><span class="calendar-prev"><a href="{$navigation.prev}"><span style="color:#cc0033;">< </span>&nbsp;previous</a></span>{/if}
{if isset($navigation.next)}
<span class="calendar-next"><a href="{$navigation.next}">next&nbsp;<span style="color:#cc0033;">></span></a></span>{/if}</div>
<div class="month_name">{if $day > 0}{$day} {/if}{$month_names[$month]} {$year}</div>
<div style="clear:both;"></div>
</div>
{/if}

{foreach from=$events key=key item=event}
....rest of code
{/foreach}
Post Reply

Return to “Modules/Add-Ons”