News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Monthly Calendar pictures

Started by bulliedog, September 21, 2004, 09:38:03 AM

Previous topic - Next topic

bulliedog

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

[Unknown]

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]

bulliedog

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?


[Unknown]

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".

-[Unknown]

bulliedog

Perfect!  Thanks for the explanation. :D

rojamaia

this one is good!

thanks for the tip!

Bulakbol

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

dani_ro

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.

Succubus Evaligan

#8
I love it. I like the idea. *^.^*

Somebody can tellme what I do wrong?  :'(
Yuri Goddess

dannbass

Can you post the code you are using? and we can start from there.

Bablorub

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

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

willerby

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. :)

willerby

What type of washing machine is September?

An autumnatic. :)


FlixyaFriend

Thanks for cleaning up the code.
samsung ue46c8000 [nofollow]

tumbler

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!

DakOon


JBlaze

Jason Clemons
Former Team Member 2009 - 2012


Rafferty

This may be even better if you could call a random image from an existing gallery folder without having to rename the images. Possible?
Don't Follow me I got No Idea what I'm Doing

Antechinus

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.

ndesigns

Thanks for cleaning up the code.

TheListener

Has anyone actually done this?

Does the original code still work?

John Willson

Hello,thanks for the tips.


www.triconsol.com
solutions2seo.blogspot.com

John Willson

Hi,very good idea,thanks for the tip.




JPA

Yep, Ilike this alot! will be using this today. Thanks :D
As above, so below.

lucas-ruroken

Adk Portal 3.1 is coming....

Design your universe!

marwan

Hi,

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

Advertisement: