Change no of months for mobile version

Help with installation and general calendar setttings

Change no of months for mobile version

Postby numptyboy » Tue Dec 11, 2012 11:20 pm

I'm creating a query mobile version of my site - I need to display only one or two months on the mobile site but Id like to still have 3 months on the desktop site.

I've tried to duplicate the calendar admin files and place them in a different directory and have 2 different admin panels but I can't seem to separate the two settings.

Obviously It'd be ideal if they both worked from the same database but had slightly different configurations. I'm using an iframe just now as I'm not a great coder but I'd be happy to give it a bash if needs be.

Cheers
numptyboy
 
Posts: 7
Joined: Tue Aug 14, 2012 11:13 am

Re: Change no of months for mobile version

Postby chris » Wed Dec 12, 2012 9:05 pm

Hi,
This actually should be fairly simple as the code is already prepared for the number of months to be overridden if required.

All you need to do is defined the $_GET["num_months"] variable BEFORE you include the
calendar file in your code.
eg.
Code: Select all
$_GET["num_months"]=1;
$the_file="ac-includes/cal.inc.php";
if(!file_exists($the_file)) die("<b>".$the_file."</b> not found");
else      require_once($the_file);


So, you will need to set this according to the device being used.
If you dont't define this variable, the code defaults to the number that you set via the admin panel

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Change no of months for mobile version

Postby numptyboy » Fri Dec 14, 2012 1:01 pm

Thanks Chris,

Which file does the code need to be altered in and what should I alter it to. I'm pretty new to all of this.

I really appreciate your help..
numptyboy
 
Posts: 7
Joined: Tue Aug 14, 2012 11:13 am

Re: Change no of months for mobile version

Postby chris » Fri Dec 14, 2012 8:06 pm

That line needs to be added to the calendar > index.php file.
IE the one that you are including in your site.

However you will need to adjust the number of months according to the device being used.

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Change no of months for mobile version

Postby Razoredger » Fri May 16, 2014 6:28 pm

I couldn't get the code working because I donot know how to adjust the number of months according to the device within the existing code.
I tried and if else statement using the code above, without succes.

What I finally opted to force one month display on mobile devices, is to clone the page for mobile with the adjusted number of months set in the iframe. A javascript code was added to the desktop webpage to redirect user if mobile device detected like this:
Code: Select all
<script type="text/javascript">
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) { window.location = "reservations_m.html" }
</script>

The downside here is the existence of a cloned page, a GG no-no, to which a nofollow tag has been added for appeasement.

This is my quick and dirty solution.
I'm wondering, is there is a better way?
User avatar
Razoredger
 
Posts: 12
Joined: Tue Aug 30, 2011 4:09 pm
Location: Indian Rocks Beach

Re: Change no of months for mobile version

Postby chris » Sat May 17, 2014 9:59 am

If you have this JavaSCript code to detect the device:
Code: Select all
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) { window.location = "reservations_m.html" }

you could just use that same code to define the number of months on the original calendar code.
i.e. change this
Code: Select all
var months_to_show      = <?php echo AC_NUM_MONTHS; ?>; // number of months to show

to this:
Code: Select all
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) { var months_to_show=1; }
else{var months_to_show      = <?php echo AC_NUM_MONTHS; ?>; }


Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Change no of months for mobile version

Postby Razoredger » Tue May 20, 2014 1:44 am

Hi Chris,
I had already tried an if else statement but it didn't work. I will now try this.

Regards
User avatar
Razoredger
 
Posts: 12
Joined: Tue Aug 30, 2011 4:09 pm
Location: Indian Rocks Beach

Re: Change no of months for mobile version

Postby Razoredger » Tue May 20, 2014 5:18 pm

Just to give some feedback info, I swapped out the code as suggested in index.php, but it still shows 3 months calendar on my iphone. Here's what is in index.php now.
Code: Select all
<script type="text/javascript">
   //   define vars
   var url_ajax_cal       = '<?php echo AC_DIR_AJAX; ?>calendar.ajax.php'; // ajax file for loading calendar via ajax
   var img_loading_day      = '<?php echo AC_DIR_IMAGES; ?>ajax-loader-day.gif'; // animated gif for loading
   var img_loading_month   = '<?php echo AC_DIR_IMAGES; ?>ajax-loader-month.gif'; // animated gif for loading
   //   don't change these values
   var id_item          = '<?php echo ID_ITEM; ?>'; // id of item to be modified (via ajax)
   var lang             = '<?php echo AC_LANG; ?>'; // language
    var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
                if (mobile) { var months_to_show=1; }
                else {var months_to_show      = <?php echo AC_NUM_MONTHS; ?>; }
   var clickable_past      = '<?php echo AC_ACTIVE_PAST_DATES; ?>'; // previous dates
   </script>


I'm using an iframe for display if that makes a difference.
Here's the iframe code I have, with lang variable:

Code: Select all
<iframe class="sixteen columns calendrier" frameborder=0 scrolling=no allowtransparency=true
           src="http://www.domainname.com/calendar/?id_item=1&lang=fr"></iframe>


Regards,
User avatar
Razoredger
 
Posts: 12
Joined: Tue Aug 30, 2011 4:09 pm
Location: Indian Rocks Beach


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests