Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: bulliedog on September 21, 2004, 09:38:03 AM

Title: Monthly Calendar pictures
Post by: bulliedog on September 21, 2004, 09:38:03 AM
Just thought I would share a really easy way to have different pictures show up for each month in the calendar.

Add the code below to your theme's Calendar.template.php where you want the pictures to appear.  I put the code right below the following line: global $context, $settings, $options, $txt, $scripturl, $modSettings, $months, $months_short, $days;

echo '<div align="center"><img border="1" src="http://yourdomain.com/images/calendar/', $months[$context['current_month']], '.jpg' , '"></div>';


In the above, substitute the correct path to the directory where your images are stored. 

The code places a center aligned image right above the calendar table.  Then all you have to do is upload the pictures you want to use to the specified image directory.  Make sure the images are named after the month you want them to appear for. Example: January, February, etc. 

With the code above all pictures must be jpg format. 

That's it.  I hope someone finds this useful.

James
Title: Re: Monthly Calendar pictures
Post by: [Unknown] on September 21, 2004, 03:44:48 PM
I would use:

echo '<div align="center"><img src="http://yourdomain.com/images/calendar/month', $context['current_month'], '.jpg" border="1" alt="" /></div>';

Because it's more valid xhtml, and it's more internationalizable.  Note that you have to use numbers now, for example month10.jpg.

-[Unknown]
Title: Re: Monthly Calendar pictures
Post by: bulliedog on September 21, 2004, 03:58:23 PM
Thanks for cleaning up the code.  Question: When you say that you have to use numbers now, is that just in your example then because you dropped the $months in front of $context?

Title: Re: Monthly Calendar pictures
Post by: [Unknown] on September 21, 2004, 09:47:04 PM
Quote from: bulliedog on September 21, 2004, 03:58:23 PM
Thanks for cleaning up the code.  Question: When you say that you have to use numbers now, is that just in your example then because you dropped the $months in front of $context?

Sorry, I was a bit unclear.  Yes, the $months array contains a list of all the month names in "your favorite language".  In Dutch, none of those names are "January".

So, if I were to use your code on this site, some people would end up seeing missing images... my solution is to use the number instead, which is the same for everyone.  By taking off the $months part, I go from:

$months[$context['current_month']]  -->  $months[1]  -->  'January'

To:

$context['current_month']  -->  1

So all I have to do now is make an image named "month1.jpg" and it will be used for any language.  That's what I meant by "internationalization" (http://en.wikipedia.org/wiki/Internationalization).

-[Unknown]
Title: Re: Monthly Calendar pictures
Post by: bulliedog on September 21, 2004, 10:48:33 PM
Perfect!  Thanks for the explanation. :D
Title: Re: Monthly Calendar pictures
Post by: rojamaia on August 27, 2005, 12:06:05 PM
this one is good!

thanks for the tip!
Title: Re: Monthly Calendar pictures
Post by: Bulakbol on May 08, 2007, 03:40:06 PM
Yah, this is good. How about daily and or weekly?  I'm new to SMF.
Title: Re: Monthly Calendar pictures
Post by: dani_ro on June 07, 2007, 03:54:30 PM
Is there a $context['current_year']?

I like this alot.  I'd also like to have a directory structure like this
/images/2007/
/images/2008/

and the image would be grabbed like so
echo '<div align="center"><img src="http://yourdomain.com/images/', $context['current_year'],$context['current_month'], '.jpg" border="1" alt="" /></div>';

I tried using like that but didn't seem to work.  However with /images it works just fine.
Title: Re: Monthly Calendar pictures
Post by: Succubus Evaligan on June 23, 2008, 04:39:37 PM
I love it. I like the idea. *^.^*

Somebody can tellme what I do wrong?  :'(
Title: Re: Monthly Calendar pictures
Post by: dannbass on June 24, 2008, 07:59:57 PM
Can you post the code you are using? and we can start from there.
Title: Re: Monthly Calendar pictures
Post by: Bablorub on June 26, 2008, 05:25:28 AM
Yep, thanx, i've found it useful, not vital of course but it'll go :)
Title: Re: Monthly Calendar pictures
Post by: edi67 on July 23, 2008, 02:33:36 AM
done in smf2 thx
Title: Re: Monthly Calendar pictures
Post by: willerby on January 13, 2009, 04:11:18 PM
Could anyone suggest where to put this code in 2.0b4 to centre an image under the two smaller monthly calendars on the the left of the calendar screen?

There's a big gap here that could be filled with a suitable monthly image but not sure where to put code and how to change formatting to make this look right...

Any help gratefully appreciated

W
Title: Re: Monthly Calendar pictures
Post by: willerby on January 16, 2009, 07:01:37 PM
Any takers?
Title: Re: Monthly Calendar pictures
Post by: enjoy1985 on January 25, 2009, 10:26:43 PM
thanks for the tip! 8)
Title: Re: Monthly Calendar pictures
Post by: FlixyaFriend on January 30, 2009, 11:18:30 AM
Thanks for cleaning up the code.
Title: Re: Monthly Calendar pictures
Post by: tumbler on February 20, 2009, 11:58:57 PM
This works really well for our site, where each month we use a member's photo on the calendar. What would it take to add a photo credit below the monthly picture?

Thanks!
Title: Re: Monthly Calendar pictures
Post by: DakOon on February 25, 2009, 09:17:47 AM
Thanks for the explanation.
Title: Re: Monthly Calendar pictures
Post by: JBlaze on April 24, 2009, 07:52:21 PM
Very nice tip. Props :)
Title: Re: Monthly Calendar pictures
Post by: MF30 on July 26, 2009, 08:37:08 PM
Good tip. :)
Title: Re: Monthly Calendar pictures
Post by: Rafferty on July 27, 2009, 10:11:50 PM
This may be even better if you could call a random image from an existing gallery folder without having to rename the images. Possible?
Title: Re: Monthly Calendar pictures
Post by: Antechinus on August 17, 2009, 02:12:21 AM
Should be possible but you'd probably want a mod made for that. I suggest putting in a mod request and specifying which gallery you are using if you want to take it further.
Title: Re: Monthly Calendar pictures
Post by: ndesigns on January 26, 2010, 09:05:27 PM
Thanks for cleaning up the code.
Title: Re: Monthly Calendar pictures
Post by: TheListener on March 15, 2010, 10:45:36 PM
Has anyone actually done this?

Does the original code still work?
Title: Re: Monthly Calendar pictures
Post by: John Willson on June 04, 2010, 03:22:57 AM
Hello,thanks for the tips.


www.triconsol.com
solutions2seo.blogspot.com
Title: Re: Monthly Calendar pictures
Post by: John Willson on June 09, 2010, 04:04:56 AM
Hi,very good idea,thanks for the tip.



Title: Re: Monthly Calendar pictures
Post by: JPA on June 23, 2010, 08:16:22 AM
Yep, Ilike this alot! will be using this today. Thanks :D
Title: Re: Monthly Calendar pictures
Post by: lucas-ruroken on June 23, 2010, 05:57:59 PM
any screen?
Title: Re: Monthly Calendar pictures
Post by: marwan on September 18, 2010, 06:16:05 AM
Hi,

I'm trying this on RC3 but couldnt find the line you specified on the first post. Please help