headhunter
Posts: 130
|
Posted: 06/06/2008, 1:51 PM |
|
Hello,
I was wondering on how to change the style of a day cell in a color='Red'>calendar if there is an event that day.
I have put the following code in the BeforeShowEvent of the color='Red'>calendar:
global $Tpl;
if (!$Component->EventTime->GetValue())
{
$Tpl->SetVar("eventstyle","");
}
else
{
$Tpl->SetVar("eventstyle","background: #AF2B17;");
}
But this way the style is applied to all cells after the current event.
Here is an example, on the 12th of june I added 3 events, but every cell after the 12th has also the custom style applied:
http://headhunter.dnsalias.org:2080/~djansa_v2/Home/ind...ng=nl&locale=nl
Thanks!
|
|
|
wkempees
Posts: 1679
|
Posted: 06/06/2008, 3:31 PM |
|
www.dubbellul.nl/color='Red'>calendar for a demo http://www.dubbellul.nl/calendar/MyBookings.php?object_id=2
post to be continued....
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
|
|
wkempees
Posts: 1679
|
Posted: 06/06/2008, 3:42 PM |
|
Old School:
In the HTML find
<!-- BEGIN Day -->
<td {Style} >{DayNumber}
Add a Label (mine is Label1), like
<!-- BEGIN Day -->
<td {Style} {Label1}>{DayNumber}
BeforeShowDay event
$Container->Label1->SetValue("");
Initialy setting the label to 'nothing'
Then BeforeShow EventDescription
//cal_color='Red'>calendar_EventDescription_BeforeShow @35-E031CC09
function cal_color='Red'>calendar_EventDescription_BeforeShow(& $sender)
{
$cal_color='Red'>calendar_EventDescription_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $cal_color='Red'>calendar; //Compatibility
//End cal_color='Red'>calendar_EventDescription_BeforeShow
//Custom Code @37-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
// $cal_color='Red'>calendar->EventDescription->SetValue('<img src="images\greenbar.gif" alt="Other">');
if ($Component->GetValue() > 2) {
$Container->Label1->SetValue(' style="background-color: green;"');
// $cal_color='Red'>calendar->EventDescription->SetValue("");
}
if ($Component->GetValue()==1) {
$Container->Label1->SetValue(' style="background-color: yellow;"');
// $cal_color='Red'>calendar->EventDescription->SetValue("");
}
if ($Component->GetValue()==2) {
$Container->Label1->SetValue('style="background-color: red;"');
// $cal_color='Red'>calendar->EventDescription->SetValue("");
}
//End Custom Code
//Close cal_color='Red'>calendar_EventDescription_BeforeShow @35-91A16806
return $cal_color='Red'>calendar_EventDescription_BeforeShow;
}
//End Close cal_color='Red'>calendar_EventDescription_BeforeShow
Add only the part between 'write you own code here'and 'end custom code'
Of course you do you own conditional.
New School
Instead of a Label add an attribute (right click in HTML same place choose add attribute) and give it a name f.i. backcolor
And manage the attribute in almost the same way.
$Component->Attributes->SetValue('backcolor', '');
$Component->Attributes->SetValue('backcolor', 'style="background-color: red;"');
HTH
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
|
|
headhunter
Posts: 130
|
Posted: 06/07/2008, 1:45 AM |
|
Hello Walter,
thanks for your solution.
One thing, the code
$Container->Label1->SetValue("");
Should go in the BeforShowDay event, otherwise it doesn't work.
Now mine is working :)
Thanks!
|
|
|
wkempees
Posts: 1679
|
Posted: 06/07/2008, 3:01 AM |
|
@H
Ammended in this Post, but works ok for me.
Please change title to {TIP} or [ RESOLVED]
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
|
|
martin47
Posts: 35
|
Posted: 06/12/2008, 8:34 AM |
|
Greetings. Im trying to achieve this effect but i get this error:
Fatal error: Call to a member function SetValue() on a non-object
My line is
$Container->COLOREADOR->SetValue("");
The line is in the before show day event. Am I missing some code?
|
|
|
headhunter
Posts: 130
|
Posted: 06/12/2008, 9:29 AM |
|
martin47,
probably you referenced to the wrong object.
Is the object located in an include page?
Or in a normal page?
Or...
|
|
|
|