Page 1 of 1

How many months -> edit with PHP?

PostPosted: Mon Jul 12, 2010 5:13 pm
by olliu
Hello, sorry if my English is bad.

I want to implement your great Calendar into a CMS. Therefore I want the "How many months" option not only editable in the admin panel. Is this possible, e.g. with PHP ?

I want soemthing like: Let the iframe be 500px tall if the User in the CMS wants only 4 months to be visible and so on. So that the User don't has to login and the iframe is dynamically as tall as the amount of months.

Thx.

Re: How many months -> edit with PHP?

PostPosted: Wed Jul 14, 2010 4:14 pm
by chris
Hello,
If I understand you correctly you want to be able to overwrite the default number of months to show that is defined in the admin. Is that correct?

If so, you can do the following:

1. in the calendar > index.php file (or the file where you are actually showing the calendar) add this line right BEFORE you include the cal.inc.php file:
Code: Select all
$num_months=4;


Then you need to open up the ac-includes > common.inc.php file and change this line (ln 29):
Code: Select all
define("CAL_MONTHS_TO_SHOW" , "".$row_config["num_months"]."");

to this:
Code: Select all
if(isset($num_months)){
   define("CAL_MONTHS_TO_SHOW" , "".$num_months."");
}else{
   define("CAL_MONTHS_TO_SHOW" , "".$row_config["num_months"]."");
}


Hopefully you will see that that last change simply checks to see if the $num_months vairable has been defined and uses it, otherwise it uses the admin defined value.

Now, you might want to actually pass the num months to the calendar via the iframe (I don't really know what you are doing so I am not sure of the exact solution in your case). If so, change the line that we added earlier:
Code: Select all
$num_months=4;

to something like this:
Code: Select all
if(isset($_GET["num_months"])){
  $num_months=$_GET["num_months"];
}

(you should also validate that the variable has a numeric value)

Then, simply append the num_months variable to your iframe url something like this:
Code: Select all
src="/calendar/index.php=num_months=4"



Let me know if this is not what you wanted or if you have any problems.

Chris

Re: How many months -> edit with PHP?

PostPosted: Fri Jul 16, 2010 10:05 am
by olliu
it did work thx

you just called
Code: Select all
CAL_MONTHS_TO_SHOW
->
Code: Select all
AC_NUM_MONTHS