Page 1 of 1

extended display of CGCalendar

Posted: Sun Mar 06, 2011 7:05 pm
by backwoodsman
I need to show the defaultCGCalendar output, i.e. the one-month view, but multiple times putting each successive month into a div. This way the user can see a 9-month or 12-month view. Then I want to allow paging forward/backward in, say, 6-month hops.

I have tweaked the css to get the single month how I need it, but I am not sure what is the most efficient way to get the extended diplay. If I try to do it in the page, it will result in some convoluted logic to call the module multiple times with the correct parameters, and paging forward/backward -- well, I'm not sure I can see how to start that. It would be easy to write a plugin or UDT to do the logic and layout, but I don't think you can call a module from there. The alternative is to try to modify the display section of the module itself to accept an additional parameter and give the extended display...

Any advice on an efficient approach?

Re: extended display of CGCalendar

Posted: Sun Mar 06, 2011 9:25 pm
by Wishbone
backwoodsman wrote:It would be easy to write a plugin or UDT to do the logic and layout, but I don't think you can call a module from there.
You can call any module's Smarty tag from a UDT.. I use {Gallery img=$img} in one of my UDTs..

Code: Select all

echo smarty_function_eval(array('var'=>"{Gallery img=$img}"), $smarty);

Re: extended display of CGCalendar

Posted: Sun Mar 06, 2011 9:45 pm
by backwoodsman
Wishbone wrote: You can call any module's Smarty tag from a UDT..
Thanks. That will be the way forward then.

It's difficult to find intelligible information on smarty functions -- or even a catalog of them. I have finally located http://www.smarty.net/docsv2/en
and expect everything is there somewhere -- just have to keep searching.

I'm marking this solved in anticipation :-)

Re: extended display of CGCalendar

Posted: Sun Mar 06, 2011 10:34 pm
by Wishbone
There's another way to do it, which I used before I found smarty_function_eval

UDT:
$smarty->assign('gallery', "{Gallery img=$img}");

Template:
{eval var=$gallery}

Re: extended display of CGCalendar

Posted: Wed Mar 09, 2011 10:55 pm
by backwoodsman
In fact, those useful tips do not seem to help. I need to call CGCalendar 12 times, once for each successive month, and assemble the outputs into a single page. There is no neat way to put a for loop on the page itself (and I would rather not do it there as I also want logic to allow paging forward 6 months at a time). Ideally the UDT or plugin would do something like this

Code: Select all

    $yayear = date('Y');
    $yamonth = date('m');
    $mayear = $yayear;
    for ($i = 0; $i < 12; $i++ ) {
        $mamonth = $yamonth + $i;
        if ( $mamonth > 12 ) {
            $mamonth = $mamonth - 12;
            $mayear++;
        }
#now I need to allocate to a variable, say $madiv, the output of {cms_module module="CGCalendar" calendartemplate='a-cal' year=$mayear month=$mamonth}
#then I could
        $outtext .= "<div>$madiv</div>";
    }
Ignoring all the style issues and the paging forward, of course.

I could start from scratch and write a whole new calendar, with its own db access etc, but it seems crazy that I cannot see a way to use the very good one Calguy wrote.