Advertisement:

Author Topic: Monthly Calendar pictures  (Read 68919 times)

Offline bulliedog

  • Semi-Newbie
  • *
  • Posts: 94
  • Gender: Male
  • No really...I'm a llama!
Monthly Calendar pictures
« 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;

Code: [Select]
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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Monthly Calendar pictures
« Reply #1 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]

Offline bulliedog

  • Semi-Newbie
  • *
  • Posts: 94
  • Gender: Male
  • No really...I'm a llama!
Re: Monthly Calendar pictures
« Reply #2 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?


Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Monthly Calendar pictures
« Reply #3 on: September 21, 2004, 09:47:04 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".

-[Unknown]

Offline bulliedog

  • Semi-Newbie
  • *
  • Posts: 94
  • Gender: Male
  • No really...I'm a llama!
Re: Monthly Calendar pictures
« Reply #4 on: September 21, 2004, 10:48:33 PM »
Perfect!  Thanks for the explanation. :D

Offline rojamaia

  • Semi-Newbie
  • *
  • Posts: 83
Re: Monthly Calendar pictures
« Reply #5 on: August 27, 2005, 12:06:05 PM »
this one is good!

thanks for the tip!

Offline Bulakbol

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,220
  • Gender: Male
  • JohnyB
Re: Monthly Calendar pictures
« Reply #6 on: May 08, 2007, 03:40:06 PM »
Yah, this is good. How about daily and or weekly?  I'm new to SMF.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Offline dani_ro

  • Newbie
  • *
  • Posts: 5
Re: Monthly Calendar pictures
« Reply #7 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="hxxp:yourdomain.com/images/ [nonactive]', $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.

Offline Succubus Evaligan

  • Jr. Member
  • **
  • Posts: 274
  • Gender: Female
    • Yurilandia
Re: Monthly Calendar pictures
« Reply #8 on: June 23, 2008, 04:39:37 PM »
I love it. I like the idea. *^.^*

Somebody can tellme what I do wrong?  :'(
« Last Edit: June 24, 2008, 07:24:06 PM by Succubus Evaligan »
Yuri Goddess

Offline dannbass

  • Sr. Member
  • ****
  • Posts: 768
  • Ex.php?erto
Re: Monthly Calendar pictures
« Reply #9 on: June 24, 2008, 07:59:57 PM »
Can you post the code you are using? and we can start from there.

Offline Bablorub

  • Newbie
  • *
  • Posts: 2
Re: Monthly Calendar pictures
« Reply #10 on: June 26, 2008, 05:25:28 AM »
Yep, thanx, i've found it useful, not vital of course but it'll go :)
hxxp:www.love-vs-hate.com/ [nonactive] - viewpoint
hxxp:www.mybestcity.com [nonactive] - boyz & girlz
hxxp:www.newbabyassistant.com [nonactive] - lil' men

Offline edi67

  • SMF Hero
  • ******
  • Posts: 1,532
  • Gender: Male
  • Italian Supporter
    • CrazyZone
Re: Monthly Calendar pictures
« Reply #11 on: July 23, 2008, 02:33:36 AM »
done in smf2 thx
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Offline laetabi

  • Full Member
  • ***
  • Posts: 427
  • Gender: Male
Re: Monthly Calendar pictures
« Reply #12 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
What type of washing machine is September?

An autumnatic. :)

Offline laetabi

  • Full Member
  • ***
  • Posts: 427
  • Gender: Male
Re: Monthly Calendar pictures
« Reply #13 on: January 16, 2009, 07:01:37 PM »
Any takers?
What type of washing machine is September?

An autumnatic. :)


Offline FlixyaFriend

  • Semi-Newbie
  • *
  • Posts: 18
    • samsung ue46c8000
Re: Monthly Calendar pictures
« Reply #15 on: January 30, 2009, 11:18:30 AM »
Thanks for cleaning up the code.

Offline tumbler

  • Semi-Newbie
  • *
  • Posts: 25
Re: Monthly Calendar pictures
« Reply #16 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!


Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,152
    • @fragicide on Twitter
Re: Monthly Calendar pictures
« Reply #18 on: April 24, 2009, 07:52:21 PM »
Very nice tip. Props :)

Offline MF30

  • Jr. Member
  • **
  • Posts: 119
    • Futebol Tuga
Re: Monthly Calendar pictures
« Reply #19 on: July 26, 2009, 08:37:08 PM »
Good tip. :)