extended display of CGCalendar

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
backwoodsman
Forum Members
Forum Members
Posts: 38
Joined: Tue Dec 30, 2008 1:09 pm

extended display of CGCalendar

Post 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?
Last edited by backwoodsman on Wed Mar 09, 2011 10:27 pm, edited 2 times in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: extended display of CGCalendar

Post 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);
backwoodsman
Forum Members
Forum Members
Posts: 38
Joined: Tue Dec 30, 2008 1:09 pm

Re: extended display of CGCalendar

Post 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 :-)
Last edited by backwoodsman on Wed Mar 09, 2011 10:28 pm, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: extended display of CGCalendar

Post 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}
backwoodsman
Forum Members
Forum Members
Posts: 38
Joined: Tue Dec 30, 2008 1:09 pm

Re: extended display of CGCalendar

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

Return to “Modules/Add-Ons”