Avoid hard-coding the starting month

Avoid hard-coding the starting month

Postby keyboarder » Wed Nov 03, 2010 6:05 pm

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 ?
keyboarder
 
Posts: 11
Joined: Tue Oct 19, 2010 3:21 pm

Re: Avoid hard-coding the starting month

Postby chris » Wed Nov 03, 2010 7:58 pm

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
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Avoid hard-coding the starting month

Postby keyboarder » Thu Nov 04, 2010 2:32 pm

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 !
keyboarder
 
Posts: 11
Joined: Tue Oct 19, 2010 3:21 pm

Re: Avoid hard-coding the starting month

Postby chris » Thu Nov 04, 2010 2:48 pm

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
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Avoid hard-coding the starting month

Postby keyboarder » Sat Apr 09, 2011 11:30 am

Hi,

just go to http://www.ajaxavailabilitycalendar.com/docs and follow step by step the instructions there. Good luck.
keyboarder
 
Posts: 11
Joined: Tue Oct 19, 2010 3:21 pm

Re: Avoid hard-coding the starting month

Postby joed89 » Thu May 12, 2011 7:08 am

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.
joed89
 
Posts: 5
Joined: Wed May 11, 2011 1:02 pm

Re: Avoid hard-coding the starting month

Postby azchipka » Sun Apr 01, 2012 2:08 am

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.
azchipka
 
Posts: 3
Joined: Sun Apr 01, 2012 12:36 am


Return to General Topics

Who is online

Users browsing this forum: No registered users and 2 guests

cron