Page 1 of 1

CGCalendar 1.15.3 and Smarty

Posted: Thu Aug 13, 2015 10:53 pm
by cpansewicz
Hi,


Somebody had previously helped me put together this great code to switch between Calendar View and List View in CMS 1.11.4, with CG Calendar 1.10.4 (see below).

I just updated my CMS to 1.12, and my cgcalendar to 1.15.3.
When I put the code into my updated CMS, it no longer does switches between the views. Could somebody look to see if there is something that needs to be changed?

CODE on page:
{if $smarty.get.view == 'list'}{$calendarview='list'}{else}{$calendarview='calendar'}{/if}
<div class="cal-calendar">
{cms_module module="CGCalendar" display=$calendarview calendartemplate="calendarview" listtemplate="listview" category="Calendar of Events"}
</div>

CODE in calendar template:
<div class="change-view">
<h4>Calendar View:
{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}
</h4>
</div>

Re: CGCalendar 1.15.3 and Smarty

Posted: Fri Aug 14, 2015 8:46 am
by velden
I would expect it to change views but not providing the proper link when in 'list view'

Try this:

Code: Select all

{if $smarty.get.view == 'list'}{$calendarview='list' scope=global}{else}{$calendarview='calendar' scope=global}{/if}
<div class="cal-calendar">
{cms_module module="CGCalendar" display=$calendarview calendartemplate="calendarview" listtemplate="listview" category="Calendar of Events"}
</div
Add scope=global twice. It will make the variable available to the CGCalendar template too (which is another scope than page template/content)

SOLVED: CGCalendar 1.15.3 and Smarty

Posted: Fri Aug 14, 2015 2:55 pm
by cpansewicz
Thank you for suggesting that. I did implement it in the code. I found the error though. In the original version of the code I had "page=$page_alias". This worked in CGCalendar 1.10.4.

I changed "$page_alias" to the actual alias of the page (i.e. 'events'), and now the code works. I'm not sure why it would work with $page_alias in one place and not in another.

Thank you for replying to my post.