Date function to pull in images instead of text

Home Forums Calendar Products Events Calendar PRO Date function to pull in images instead of text

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1014788
    Gina
    Participant

    I have a website which had a very old version of The Events Calendar, they were pulling in the date and month of each event with images instead of numbers like so: http://www.agilebear.com/events

    I am trying to get this same code working with the latest version of The Events Calendar. The image block is being pulled in with this code:

    <div class="date-block">
    	<? echo dateImage(the_event_start_date($post->ID, false, 'd'), the_event_end_date($post->ID, false, 'd'), the_event_start_date($post->ID, false, 'm')); ?>
    	<div class="bot"></div>
    </div>

    There is also a bit of code in the functions file which I have tried to edit but failed:

    //
    	function dateImage($start_date, $end_date = null, $Month)
    	{
    		$test = false;
    	 	$dayImageName = $start_date;
    	 	//2 days
    	 	if($end_date != null)
    	 	{
    	 		$dayImageName = $dayImageName . '-' . $end_date;	
    	 	}
    	 	//same day
    	 	if ($start_date == $end_date)
    	 	{
    	 		$dayImageName = $start_date;
    	 	}
    	 	//more than 2 days chosen - default to show 1st day only
    	 	if (($end_date - $start_date) >= 2)
    	 	{
    	 		$dayImageName = $start_date;
    	 	}
    	 	
    		$dayImage = '<img src="' . get_bloginfo('template_directory') . '/images/furniture/calendar/ABC_Day_D_' . $dayImageName . '.gif" alt="' . $dayImageName . '" width="60" height="35" />';
    		$monthImage = '<img src="' . get_bloginfo('template_directory') . '/images/furniture/calendar/ABC_Month_' . $Month . '.gif" alt="' . $Month . '" width="60" height="15" />';
    		if($test)
    		{
    			$testString = $start_date . " : "  . $end_date . " : "  . $Month;
    		}
    		return $testString . $dayImage . "\r" . $monthImage;
    	}

    What happens is that it calls in an image based on the date – at the moment the code is pulling in each number for the start day, end day and month but it’s no corresponding with the code in the functions and pulling in the image. Here is what our testing server looks like: http://agile.rare-testing.co.uk/events

    Any help and/or ideas would be much appreciated.

    #1014836
    George
    Participant

    Sorry Gina, we unfortunately cannot offer any support for custom code here…

    With that being said, one detail that might help (after a quick look at your code examples) is to use the functions tribe_get_start_date and tribe_get_end_date instead of the_event_start_date and the_event_end_date, respectively. The latter two functions are deprecated now and have been replaced by the former two functions.

    I hope that helps at least in some sense.

    Sincerely,
    George

    #1014844
    Gina
    Participant

    Hi George,

    Brilliant help, that actually solved it. Thank you!

    #1014847
    George
    Participant

    Awesome! 😀

    Thanks for the quick update here – best of luck with your site!

    Cheers,
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Date function to pull in images instead of text’ is closed to new replies.