Page 1 of 1

Avoid hard-coding the starting month

PostPosted: Wed Nov 03, 2010 6:05 pm
by keyboarder
I have visited ALL sites listed at ajaxavailabilitycalendar.com under "Example Sites" and all sites listed here in the forum under topic "Live Sites" and looked at their availability calendars.
I have studied the PHP code, called by their iFrames and it looks to me that everybody has hard-coded the starting month, such as in this sample for a 3 months calendar view (or did I overlook something ?):

Code: Select all
<div id="the_months">
         <div id="10_2010" class="cal_month load_cal"></div>
         <div id="11_2010" class="cal_month load_cal"></div>
         <div id="12_2010" class="cal_month load_cal"></div>
      </div>


This would mean that the code has to be updated (shifted manually) every month to the next actual month! (??). If so, this would perhaps be acceptable for a single user (still Hollerith per pedes...), but it would render the calendar highly time-consuming, for a multi-user installation. (I have some xx clients, that might be interested to have the calendar installed at their websites, (including the booking page at their local host.). I cannot imagine that this has to be changed every month manually.

Did anybody find a way to let the code automatically start with the actual month, such as the "ac-admin/index.php" does ?

Re: Avoid hard-coding the starting month

PostPosted: Wed Nov 03, 2010 7:58 pm
by chris
have visited ALL sites listed at ajaxavailabilitycalendar.com under "Example Sites" and all sites listed here in the forum under topic "Live Sites" and looked at their availability calendars.

How can you tell from their html source code how the date is set? I think it highly unlikely that any of those sites have set the starting month manually.
<div id="the_months">
<div id="10_2010" class="cal_month load_cal"></div>
<div id="11_2010" class="cal_month load_cal"></div>
<div id="12_2010" class="cal_month load_cal"></div>
</div>

That code snippet is created dynamically by the php.
Did anybody find a way to let the code automatically start with the actual month, such as the "ac-admin/index.php" does ?

By default the code selects the current month as the starting month.
The only reason for hard coding it is if you want it to start in a sepecific month. For example some people like to show a calendar year (Jan to Dec) rather than from the current month.

Chris

Re: Avoid hard-coding the starting month

PostPosted: Thu Nov 04, 2010 2:32 pm
by keyboarder
Hi Chris,
of course I'm not only looking in their html code. I look into the source of the PHP code, called by the iFrame. When I said: "...it looks to me..."

that means: It only LOOKS to me, AS IF everybody uses hard-coding. But your remark
that the code snippet is created dynamically by the php
and thus comes back with the months already in place, brought me again a whole step further. Thanks !

I'm definitely a PHP beginner (!), but I'm eager to learn ! And I tell you what: With your awesome code, your help, all the remarks here in the forum and my "studies" I'll get that script running the way I need it - step by step - you wait, I'm almost done ! :D
Thanks again !

Re: Avoid hard-coding the starting month

PostPosted: Thu Nov 04, 2010 2:48 pm
by chris
I look into the source of the PHP code, called by the iFrame

The only way that you can see the php code is by looking at the original file in the ftp, and, unless you are an expert hacker, I don't think you will be able to do withour their permission.
When you look at the source code you are looking at the html code generated by the php, not the php code itself.
I can ensure you that the months are created dynamically ;)

Chris

Re: Avoid hard-coding the starting month

PostPosted: Sat Apr 09, 2011 11:30 am
by keyboarder
Hi,

just go to http://www.ajaxavailabilitycalendar.com/docs and follow step by step the instructions there. Good luck.

Re: Avoid hard-coding the starting month

PostPosted: Thu May 12, 2011 7:08 am
by joed89
I would have to agree that values which could be computed should not be hard coded in the program to make it more dynamic. Though, you could still choose to hard code it, which I bet is how most systems are implemented. I also think that it would be easier to change the settings if you can compute for the values and not the hard coded values.

Re: Avoid hard-coding the starting month

PostPosted: Sun Apr 01, 2012 2:08 am
by azchipka
None of those sites are using hardcoding the starting month is all being generated by the php code. As noted above there is no way you could see the php code with out having access to actual php script file. All the code you are looking at is dynamic in nature.