I'm trying to figure out how accomplish this:
a) in Calendar Block (mini calendar) click in a day that has an event (1)
b) then a list with all the events of that day shows up below the calendar, when clicking in the event name (2)
c) the event node is opened (in the same window).

Any help is apreciated, thanks in advance!

CommentFileSizeAuthor
goal.png70.92 KBmarco_cruz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marco_cruz’s picture

Answering to myself...
1st
Edit the file theme.inc (sites\all\modules\calendar\theme), line 535.
$vars['class'] = 'mini-day-on ';
to
$vars['class'] = 'mini-day-on '.$date;
this way you get <div class="month mini-day-on yyyy-mm-dd"> the date values to use later...

2nd
Create a block to show titles of the "Calendar" content type, with to exposed fields: Start Date (operator: Is less than or equal to) AND End Date (operator: Is greather tham or equal to) and an Apply button.
3rd
Use jQuery/javascript to do the magic.
Put the code below at the bottom of your page.tpl.php

<script type="text/javascript">
(function ($) { 
	$(document).ready(function(){
		$(".mini-day-on a").removeAttr('href');   //remove the all the links in calendar
	   	var dhoje = $(".today div").attr('class'); // get the value of the class tag in the div of the current day, for instance "month mini-day-on 2012-04-10"
	   	var hoje  = dhoje.substring(18,28); // "cut" the value to obtain just the date "2012-04-10"
	    $('#edit-field-adata-value-value-date').val(hoje); // put the date in the field Start Date
		$('#edit-field-adata-value2-value-date').val(hoje); // put the date in the field End Date
		$('#edit-submit-calendario-teste').trigger('click'); // simulate the clik in the apply button to obtain today's results

    $(".mini-day-on").click(function(){ // the goal is replicate the above process when a certain day in the calendar is clicked by user
    	var datadia = this.className; // get all the classes applied to the day div clicked by the user
		var datac  = datadia.substring(18,28); // cut to obtais the date
		$('#edit-field-adata-value-value-date').val(datac); //put the date in the field Start Date
		$('#edit-field-adata-value2-value-date').val(datac); //put the date in the field End Date
		$('#edit-submit-calendario-teste').trigger('click'); // simulate the clik in the apply button to obtain today's results
    });

});
}(jQuery));
</script>

4th
Hide your exposed filters with CSS
In my test:
#views-exposed-form-calendario-teste-block-6 { display: none}

Last
I know this is not the best, or the most elegant solution, but it works! Any improvements are welcome.

The main problem I'm facing is: I need a better way to set the default values (current date) to the filters to obtain the list of today's events when the page loads an not after the page is loaded

I'm sorry for my bad english, I'm not a native english speaker

Neslee Canil Pinto’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)