CGCalendar 1.15.3 and Smarty

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 1.15.3 and Smarty

Post 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>
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: CGCalendar 1.15.3 and Smarty

Post 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)
cpansewicz
Forum Members
Forum Members
Posts: 142
Joined: Fri Jun 17, 2011 12:22 am

SOLVED: CGCalendar 1.15.3 and Smarty

Post 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.
Post Reply

Return to “Modules/Add-Ons”