Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: bulliedog in September 21, 2004, 09:38:03 VORMITTAG

Titel: Monthly Calendar pictures
Beitrag von: bulliedog in September 21, 2004, 09:38:03 VORMITTAG
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
Titel: Re: Monthly Calendar pictures
Beitrag von: [Unknown] in September 21, 2004, 03:44:48 NACHMITTAGS
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]
Titel: Re: Monthly Calendar pictures
Beitrag von: bulliedog in September 21, 2004, 03:58:23 NACHMITTAGS
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?

Titel: Re: Monthly Calendar pictures
Beitrag von: [Unknown] in September 21, 2004, 09:47:04 NACHMITTAGS
Zitat von: bulliedog in September 21, 2004, 03:58:23 NACHMITTAGS
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]
Titel: Re: Monthly Calendar pictures
Beitrag von: bulliedog in September 21, 2004, 10:48:33 NACHMITTAGS
Perfect!  Thanks for the explanation. :D
Titel: Re: Monthly Calendar pictures
Beitrag von: rojamaia in August 27, 2005, 12:06:05 NACHMITTAGS
this one is good!

thanks for the tip!
Titel: Re: Monthly Calendar pictures
Beitrag von: Bulakbol in Mai 08, 2007, 03:40:06 NACHMITTAGS
Yah, this is good. How about daily and or weekly?  I'm new to SMF.
Titel: Re: Monthly Calendar pictures
Beitrag von: dani_ro in Juni 07, 2007, 03:54:30 NACHMITTAGS
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.
Titel: Re: Monthly Calendar pictures
Beitrag von: Succubus Evaligan in Juni 23, 2008, 04:39:37 NACHMITTAGS
I love it. I like the idea. *^.^*

Somebody can tellme what I do wrong?  :'(
Titel: Re: Monthly Calendar pictures
Beitrag von: dannbass in Juni 24, 2008, 07:59:57 NACHMITTAGS
Can you post the code you are using? and we can start from there.
Titel: Re: Monthly Calendar pictures
Beitrag von: Bablorub in Juni 26, 2008, 05:25:28 VORMITTAG
Yep, thanx, i've found it useful, not vital of course but it'll go :)
Titel: Re: Monthly Calendar pictures
Beitrag von: edi67 in Juli 23, 2008, 02:33:36 VORMITTAG
done in smf2 thx
Titel: Re: Monthly Calendar pictures
Beitrag von: willerby in Januar 13, 2009, 04:11:18 NACHMITTAGS
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
Titel: Re: Monthly Calendar pictures
Beitrag von: willerby in Januar 16, 2009, 07:01:37 NACHMITTAGS
Any takers?
Titel: Re: Monthly Calendar pictures
Beitrag von: enjoy1985 in Januar 25, 2009, 10:26:43 NACHMITTAGS
thanks for the tip! 8)
Titel: Re: Monthly Calendar pictures
Beitrag von: FlixyaFriend in Januar 30, 2009, 11:18:30 VORMITTAG
Thanks for cleaning up the code.
Titel: Re: Monthly Calendar pictures
Beitrag von: tumbler in Februar 20, 2009, 11:58:57 NACHMITTAGS
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!
Titel: Re: Monthly Calendar pictures
Beitrag von: DakOon in Februar 25, 2009, 09:17:47 VORMITTAG
Thanks for the explanation.
Titel: Re: Monthly Calendar pictures
Beitrag von: JBlaze in April 24, 2009, 07:52:21 NACHMITTAGS
Very nice tip. Props :)
Titel: Re: Monthly Calendar pictures
Beitrag von: MF30 in Juli 26, 2009, 08:37:08 NACHMITTAGS
Good tip. :)
Titel: Re: Monthly Calendar pictures
Beitrag von: Rafferty in Juli 27, 2009, 10:11:50 NACHMITTAGS
This may be even better if you could call a random image from an existing gallery folder without having to rename the images. Possible?
Titel: Re: Monthly Calendar pictures
Beitrag von: Antechinus in August 17, 2009, 02:12:21 VORMITTAG
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.
Titel: Re: Monthly Calendar pictures
Beitrag von: ndesigns in Januar 26, 2010, 09:05:27 NACHMITTAGS
Thanks for cleaning up the code.
Titel: Re: Monthly Calendar pictures
Beitrag von: TheListener in März 15, 2010, 10:45:36 NACHMITTAGS
Has anyone actually done this?

Does the original code still work?
Titel: Re: Monthly Calendar pictures
Beitrag von: John Willson in Juni 04, 2010, 03:22:57 VORMITTAG
Hello,thanks for the tips.


www.triconsol.com
solutions2seo.blogspot.com
Titel: Re: Monthly Calendar pictures
Beitrag von: John Willson in Juni 09, 2010, 04:04:56 VORMITTAG
Hi,very good idea,thanks for the tip.



Titel: Re: Monthly Calendar pictures
Beitrag von: JPA in Juni 23, 2010, 08:16:22 VORMITTAG
Yep, Ilike this alot! will be using this today. Thanks :D
Titel: Re: Monthly Calendar pictures
Beitrag von: lucas-ruroken in Juni 23, 2010, 05:57:59 NACHMITTAGS
any screen?
Titel: Re: Monthly Calendar pictures
Beitrag von: marwan in September 18, 2010, 06:16:05 VORMITTAG
Hi,

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