Quote from: charless at Jun 29, 2010, 10:58 PM
Quote from: the_piper at Jun 28, 2010, 04:44 AM
However, does anyone have any ideas on how I can get two instances of this to work on a single page? It will only use the parameters of the last call on the page for all page calls.
Yes, this is a known item. The root cause is how the place holders are handled and I’m working on solving that so that a single page can have multiple instances of the mxcalendar running.
Sorry there is not a quick fix for all of them. If your just using the Event List view let me know and we can get a custom solution in place for you.
cheers
Ok I might have a solution or workaround for this. I’ve been working on this for days and have narrowed it down to caching. I’ve duplicated the classes, duplicated the snippets, re-named variables, etc and I always got the parameter set from the final call to apply to all calls. Just for the hell of it I tried calling the first instance like this:
[[mxcalendar? &mxcType=`list` &mxcTplEventListItemWrap=`home_marquee_inner` &mxcEventListMaxCnt=`1` ]]
And the second like this:
[!mxcalendar? &mxcType=`list` &mxcEventListMaxCnt=`3` !]
Voila! I was astounded on refresh to see the page lay out like I wanted it to!
However, I don’t yet know what will happen after the date of the next event passes. Because it’s using the double brackets, will it not update? Maybe I’m celebrating prematurely. I’ll have to wait a day to see if my test works.
Update: Although it printed as I wanted, because the snippet was cached, it’s not going to update properly. I got multiple instances working, with some serious hacking. Here’s a breakdown of how I got it working:
1) I’m calling the custom snippets with no parameters
2) I’m creating my own array in the snippet call and hard coding the parameters, as well as hard coding the amount of items to show ($x)
[!myCal1!]
$myCal = array(
'mxcType'=>'list',
'mxcTplEventListWrap' => null,
'mxcTplEventListItemWrap' => null,
'mxcTplEventListFirstItemWrap' => null,
'mxcEventListMaxCnt' => '3'
);
$x = 3;
//**** Build the core class ****//
if (class_exists('mxCal_APP_CLASS')) {
$myCalApp = new mxCal_APP_CLASS(); //-- second instance
$myCalApp->output='';
//**** Return the calendar component ****//
return $myCalApp->MakeCalendar($myCal, $x) ; //. $mxCalApp2->MakeCalendar($bsCalParams);
} else {
//**** Return error *****//
return 'error: mxCalendar class not found';
}
[!myCal2!]
$myCal2 = array(
'mxcType'=>'list',
'mxcTplEventListWrap' => null,
'mxcTplEventListItemWrap' => 'home_item_chunk',
'mxcTplEventListFirstItemWrap' => null,
'mxcEventListMaxCnt' => '1'
);
$x = 1;
//**** Build the core class ****//
if (class_exists('mxCal_APP_CLASS')) {
$myCalApp2 = new mxCal_APP_CLASS(); //-- second instance
$myCalApp2->output='';
//**** Return the calendar component ****//
return $myCalApp2->MakeCalendar($myCal2, $x) ; //. $mxCalApp2->MakeCalendar($bsCalParams);
} else {
//**** Return error *****//
return 'error: mxCalendar class not found';
}
Then I had to modify the class to accept my $x value instead of using the ’mxcEventListMaxCnt’.
It STILL wasn’t working at this point so I removed return$this->output; (line 1278) and replaced with:
I’m not sure what is wrong with return$this->output;, but output is what’s screwing this up. Output seems to contain the amount of items from the final calendar call, no matter what you do. I tested this and the for loops recurse the amount of times you ask them to, that’s why returning $events yields the desired result. This probably isn’t a solid fix for this problem, but it is now doing what I want it to do, so I’m happy.