I am currently developing a drupal replacement for a site I've been maintaining in ASP/Jscript. One of the pages I have developed does three database queries for each of the current and next month's entertainment acts in a particular venue in order to build a particular page showing the acts for that venue this month, and next month. Because of the way the page is designed, I need to be able to show the acts that have not yet passed.

In particular what I need to accomplish in the immediate future is to be able to view all events which begin in the current month, and all events which occur in the month after the current month.

Comments

hyperlogos’s picture

I did figure out how to work around this problem using arguments with php.

Create a new argument on "Event: Start Month" and leave all the settings alone. Open up the "argument handling code" fieldset (only there if you have permissions to use php for block visibility) and enter the following code (without the <?php and ?>):

if (!$args[0]) {
$args[0] = date('m') + 1;
}
return $args;

And just don't give an argument when you insert your view. If you do, it will set the month number. date('m') returns the number of the current month. A lowercase j is probably a better bet, but I used 'm' and it worked. It will probably work in single-digit months, too, but I can't be sure - I am sure that 'j' will work. :)

If you have multiple arguments, the first (listed) one is 0 and they increment from there. If you're not sure which is which even with this tidbit, take a look at the page source. Find this line:

<fieldset class=" collapsible"><legend>Arguments</legend><table>

And look beneath it. All the fields/pulldowns for this argument will have something like name="edit[argument][0][argdefault]" - the important part being the number in brackets after [argument]. That's your argument number.

Ultimately, I think this still needs to be a function. I should be able to pull down "next month" from the list of months under "Event: Start/End Month" because it's so useful, and so I'm trying (so far in vain) to figure out how to actually get this into the event_views.module code. Haven't found it yet, unfortunately.

hyperlogos’s picture

Whoops! This didn't actually work, I thought I had some nodes in there that it would catch if I had it wrong. I didn't. Back to the drawing board :(

hyperlogos’s picture

Okay, I really really have it now.

By the way, something is definitely broken with the insert_view.module. When this module is used to insert a view into the current page, arguments are specified, or at the very least, views acts like arguments have been specified. I don't know if it's broken in insert_view.module or in views.module or even in event_views.module for all I know. Regardless, something is whacked.

I solved my problem in two ways. One, I stopped using if statements around my arguments, and just set them no matter what. This is sad because it means I can't specify arguments. This is happy because it worked.

I also added the event year argument, because you need it to get an exact match. It doesn't actually change anything on my site yet, because all content was made this year, but it's needed for proper operation.

Anyway, add year first, then month, and then use this code:

$args[0] = date('Y');
$args[1] = date('n') + 1;
return $args;

Forget where I talked about date('j') because it was totally, utterly wrong. No idea where I got that one. This is the correct, working code to create a view that shows events from the next month. Just don't forget that any arguments you specify when displaying your view, regardless of how you accessed it, will be ignored and the values created by the php will be used.

I want to use the filter because I want this page to be maintainable by people who will never EVER have the right to write their own php on the site.