When I go to a calendar page, most pages (except for /calendar itself) have a date code appended to the URL, such as 2010-4, or 2010-W1.

I have setup a block view that when I test using the preview feature works great when I enter one of these date codes as an argument - it filters according to the type of date (year, month, day, week) but I would like the view to use the current calendar date code argument automatically. The view shows that even on calendar pages, there is no %1 (argument 1).

Its almost as if if I need an argument option in the view that says 'date code from url' instead of 'node id from url'.

I was thinking that I could perhaps use the php option in the argument setup for views to return the correct date code for the current page as the argument to use - I'm sure that would work for me, but I don't know how to determine the name of the variable that contains the date code. Does anyone know the name of the date variable that is used to generate the current calendar page?

And a separate more general question - what php code could i use to determine all the current defined variables at a certain point just in case i run into another issue like this in the future. I have been trying to use var_dump(get_defined_vars()) but that seems to only give me a partial list whenever i use it.

Thanks

Comments

dpatte’s picture

Category: feature » support
dpatte’s picture

Title: Current Calendar Date-Code Argument for View » What is Current Calendar Date-Code Argument for View?
dpatte’s picture

I can clarify my question as follows:

How can I determine the 'date-code' that is in effect for a calendar page being generated.

For example, for most calendar pages, I'm referring to the 'date-code' that is shown as the last portion of the URL such as www.mysite.com/calendar/[date-code], such as 2010-04, or 2010-W14.

And for the landing page for calendar there is no 'date-code' in the URL, but it currently shows the calendar for the current month, so as of today, its datecode would be '2010-04'.

I need the date-code so I can set it as an argument for a views block that will go onto that page.

I guess i could write php code to parse the URL, or when there is no date-code, generate a date-code using the current date, but I'm wondering if that string is already available as a variable when creating a calendar page so I can plug it into the view.

Thanks

dpatte’s picture

Title: What is Current Calendar Date-Code Argument for View? » What is a Calendar Page's Date-Code (I need as argument for view)
arlinsandbulte’s picture

You should be able to configure the default argument for this...

'Action to take if argument is not present: 'should be set to 'Provide default argument.'
'Default argument type:' should be set to 'Current Date'

dpatte’s picture

Thanks, but I tried current date and it did not work for me. Actually, Im not looking for the current date, but the current date-period where yyyy-mm refers to the whole month, and yyy-Wxx refers to the whole week.

I have resolved the issue by writing the following code using php if the date is not provided as an argument. Since this block will only be used on calendar or calendar/* pages I am using:

{ 
$s = substr($_GET['q'],9);
if (strlen($s)>0) return $s;
return date_format(date_now(), 'Y-m');
}
arlinsandbulte’s picture

I am confused why you need to go that route.
What happens when you just use the regular default argument? (this is the way it was intended to be done)
Setting the granularity of the default argument determines the type of calendar shown (year, month, week, day).

dpatte’s picture

Using the argument I generate, the granularity is ignored. It filters by day, week, month or year depending on what I give it - which is what i wanted - to filter on the granularity of the current calendar.

If i use current date, it seemed to filter on todays date, not the date period of the calendar, but i will check it again and get back to you.

arlinsandbulte’s picture

Ah OK, I don't think I was understanding your issue totally.

Let's see if I understand:
You have a calendar page showing the calendar page view (/calendar).
On that page, you ALSO are showing a calendar block.

You want the calendar block to show the same date range as the main calendar display... correct?

If that is close, arguments are not passed to blocks and one way of doing that is with some php code as it appears you have done.

Exploratus’s picture

subscribe. This is good because lets say you have an event calendar, you ca throw in an event map. VERY USEFUL!

This php code works nicely!

arlinsandbulte’s picture

Status: Active » Postponed (maintainer needs more info)

Is this issue resolved?
If not, what needs to be done?

arlinsandbulte’s picture

Status: Postponed (maintainer needs more info) » Fixed

no reply.
Assuming this is fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.