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
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]
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?
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]
Perfect! Thanks for the explanation. :D
this one is good!
thanks for the tip!
Yah, this is good. How about daily and or weekly? I'm new to SMF.
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.
I love it. I like the idea. *^.^*
Somebody can tellme what I do wrong? :'(
Can you post the code you are using? and we can start from there.
Yep, thanx, i've found it useful, not vital of course but it'll go :)
done in smf2 thx
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
Any takers?
thanks for the tip! 8)
Thanks for cleaning up the code.
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!
Thanks for the explanation.
Very nice tip. Props :)
Good tip. :)
This may be even better if you could call a random image from an existing gallery folder without having to rename the images. Possible?
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.
Thanks for cleaning up the code.
Has anyone actually done this?
Does the original code still work?
Hello,thanks for the tips.
www.triconsol.com
solutions2seo.blogspot.com
Hi,very good idea,thanks for the tip.
Yep, Ilike this alot! will be using this today. Thanks :D
any screen?
Hi,
I'm trying this on RC3 but couldnt find the line you specified on the first post. Please help