Welcome Guest   | Login   
  Search  
  Index |  Recent Threads |  Register | 


Quick Go »
Thread Status: Normal
Total posts in this thread: 4
[Change thread status] [Delete this Thread] [Move this Thread]
[Add To My Favorites] [Watch this Thread] [Post new Thread]
Author
Previous Thread This topic has been viewed 386 times and has 3 replies Next Thread
n1lykme
New Member



Joined: Jan 10, 2013
Posts: 2
Status: Offline

Edit this Post   Show next month Reply to this Post
Reply with Quote
[Delete this Thread]

The script for the dynamic calendar is messing with the menu on my responsive wordpress site and making it not work when I go mobile. Works fine in regular view. So as a solution I was thinking of creating distinct static pages on my webpage I'll just create links to. Was wondering if there is a way to write the query to be Month+1, Month+2.... with "Month" representing the current month calendar so I don't have to manually change links every month?
Thanks.
----------------------------------------
[Edit 1 times, last edit by n1lykme at Jan 10, 2013, 1:16:56 PM]
[Jan 10, 2013, 1:15:50 PM] [First IP: 68.189.164.56 - Last IP: 68.189.164.56] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Sep 15, 2004
Posts: 6027
Status: Offline
Edit this Post   Re: Show next month Reply to this Post
Reply with Quote
[Delete this Post]

We do dynamic month substitution in the title:
http://www.localendar.com/docs/display/lc/Dynamic+replacement+of+month+name+or+number

However, if I understand you correctly, you want links that automatically go to the current month, next month, etc.

The easy part is: The calendar always defaults to the current month. So
http://www.localendar.com/public/n1lykme will always be "this month"

I think you can get what you want using our "start_date" parameter(http://www.localendar.com/docs/display/lc/Your+Calendar%27s+URL+and+Parameters), a little JavaScript and Date arithmetic. Hopefully this is close enough to get you started:

<a href='http://www.localendar.com/public/n1lykme'>This Month</a><br/>
<script>
function getNextCalendarMonth(in_date)
{
if (in_date.getMonth() == 11) {
var out_date = new Date(in_date.getFullYear() + 1, 0, 1);
} else {
var out_date= new Date(in_date.getFullYear(), in_date.getMonth() + 1, 1);
}
return out_date;
}
function formatDate(in_date)
{
var out_string = "";
out_string = (in_date.getMonth()+1)+"/"+in_date.getDate()+"/"+in_date.getFullYear();
return out_string;
}

var mplus1=getNextCalendarMonth(new Date());
var mplus2=getNextCalendarMonth(mplus1);
var mplus3=getNextCalendarMonth(mplus2);
var mplus4=getNextCalendarMonth(mplus3);
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus1)+"'>This Month+1</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus2)+"'>This Month+2</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus3)+"'>This Month+3</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus4)+"'>This Month+4</a><br/>");
</script>


whoa.. too much free time today wink
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news
[Jan 13, 2013, 5:30:23 PM] [24.189.166.34] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
support
localendar Expert
Member's Avatar


Joined: Sep 15, 2004
Posts: 6027
Status: Offline
Edit this Post   Re: Show next month Reply to this Post
Reply with Quote
[Delete this Post]

I don't like the look of "Month+1, Month+2, etc"
I mean, if you really want to be "responsive", we should show the proper month names for the period. So here's the "extra-credit" version that handles that:

<a href='http://www.localendar.com/public/n1lykme'>This Month</a><br/>
<script>

var month_names = new Array ( );
month_names[month_names.length] = "January";
month_names[month_names.length] = "February";
month_names[month_names.length] = "March";
month_names[month_names.length] = "April";
month_names[month_names.length] = "May";
month_names[month_names.length] = "June";
month_names[month_names.length] = "July";
month_names[month_names.length] = "August";
month_names[month_names.length] = "September";
month_names[month_names.length] = "October";
month_names[month_names.length] = "November";
month_names[month_names.length] = "December";

function getNextCalendarMonth(in_date)
{
if (in_date.getMonth() == 11) {
var out_date = new Date(in_date.getFullYear() + 1, 0, 1);
} else {
var out_date= new Date(in_date.getFullYear(), in_date.getMonth() + 1, 1);
}
return out_date;
}
function formatDate(in_date)
{
var out_string = "";
out_string = (in_date.getMonth()+1)+"/"+in_date.getDate()+"/"+in_date.getFullYear();
return out_string;
}

var mplus1=getNextCalendarMonth(new Date());
var mplus2=getNextCalendarMonth(mplus1);
var mplus3=getNextCalendarMonth(mplus2);
var mplus4=getNextCalendarMonth(mplus3);
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus1)+"'>"+month_names[mplus1.getMonth()]+"</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus2)+"'>"+month_names[mplus2.getMonth()]+"</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus3)+"'>"+month_names[mplus3.getMonth()]+"</a><br/>");
document.write("<a href='http://www.localendar.com/public/n1lykme?start_date="+formatDate(mplus4)+"'>"+month_names[mplus4.getMonth()]+"</a><br/>");
</script>


This seemed FAQ-worthy: http://www.localendar.com/docs/display/lc/Dynamic+links+to+multiple+calendar+months
----------------------------------------
Marc Higgins
Support Associate, localendar.com
Follow us on Twitter! http://www.twitter.com/localendar_news
----------------------------------------
[Edit 1 times, last edit by support at Jan 13, 2013, 5:43:51 PM]
[Jan 13, 2013, 5:35:57 PM] [First IP: 24.189.166.34 - Last IP: 24.189.166.34] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
n1lykme
New Member



Joined: Jan 10, 2013
Posts: 2
Status: Offline

Edit this Post   biggrin   Re: Show next month Reply to this Post
Reply with Quote
[Delete this Post]

Awesome! Great solution and customer support! Better than what I imagined.
Thank you so much!
[Feb 13, 2013, 5:01:45 PM] [68.189.164.56] Show Post Printable Version [Link] Report threatening post: please login first  Go to top 
[Show Thread Printable Version] [Post new Thread]

Help! | Cobranding | Legal | Privacy Policy | About localendar.com | Contact Us