Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8026 Posts in 1851 Topics- by 2099 Members - Latest Member: roi
Pages: [1] 2   Go Down
Print
Author Topic: adding icons  (Read 834 times)
0 Members and 1 Guest are viewing this topic.
Marc
New Member
*

Karma: 0
Offline Offline

Posts: 0

Computer tech


WWW
« on: April 18, 2005, 12:41:00 PM »

Want to say first off how great the CalendarScript is.  When I receive my last donator's check I am going to get the $50 for it in as quickly as I can, definitely worth it, guys.

Anyway, I liked the mod for adding the ability to have colorized events (add event title allow color choice to display) but wanted to have small icons for various events too.  

After playing around with the changes made in the above-mentioned thread I was able to use this as a starting point to adding code to reference small graphics.  I think it came out well.

Basically I used the modification to DEFAULT.HTML but added the following right after the line:

$details->{'title'} = "<font color='" . $details->{'color'} . "'>" . $details->{'title'} . "</font>";

Added these lines - >

$bullet = "bullet|computer|malefemale|woman|beer|chili|burger|chickenleg|wheel|tractor|basketball|football|baseball|extinguisher|guitar|fish";

if ($details->{'icon'} =~ /$bullet/) {

$details->{'title'} = "<img src=http://www.myfilehut.com/userfiles/jeffcocalendar/" . $details->{'icon'} . ".gif border=0>" . $details->{'title'};
}

I then used the free image site, MyFilehut, and uploaded small icons corresponding to each item in the "$bullet=..." line (the ones divided by |).

Then I went into the Admin and "Customize Event Fields" and added an "icon" entry.  For the "Input Type" I added "selectbox" and for each selection box I added one of the names of the above graphic icons (each one from the "$bullet=..." section) and made sure "Display in Add Field" was turned on.

Now I can select both the icon graphic as well as the color.  

You can see the results at http://calendar.jeffcowebboard.com

I hope I explained this properly.

The next thing I will do is take out the line which has the names of all of the graphic icons and add a line to read a file containing these names instead.

*Edited previous message link*

[This message has been edited by DanO (edited April 18, 2005).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: April 18, 2005, 12:53:00 PM »

That's different. Thanks for posting the code.

Dan O.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #2 on: April 18, 2005, 06:56:00 PM »

BTW. If you named all your icons similarly like: icon-bullet.gif, icon-computer.gif, icon-malefemale.gif,
you wouldn't need the $bullet = "bullet|computer... line and instead could just use this for the conditional:

if ($details->{'icon'} =~ /icon/) {

That would also allow you to add additional icons at any time without
having the manually edit the template as well.

JFYI

Dan O.


[This message has been edited by DanO (edited April 18, 2005).]

Logged
Marc
New Member
*

Karma: 0
Offline Offline

Posts: 0

Computer tech


WWW
« Reply #3 on: April 18, 2005, 07:59:00 PM »

Very nice, thanks!  Will add.

Marc

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #4 on: April 19, 2005, 02:28:00 AM »

If you have one option which was blank (for when no icon was wanted), just the following would surfice for the conditional:

if ($details->{'icon'}) {

For any event which didn't have an icon selected, the conditional operation would just be skipped.

JFYI

Dan O.

------------------

Logged
Marc
New Member
*

Karma: 0
Offline Offline

Posts: 0

Computer tech


WWW
« Reply #5 on: April 20, 2005, 10:03:00 AM »

Even better, but I ended up not needing your addition for mine (see "I did make another mod also..." below).

But I did find one problem - apparently this routine is called more then once for events that span multiple days or are recurring.  So in that case every time it hits that loop it keeps adding multiple icons.  So I included the line -

if ($details->{'title'} !~ /.gif/) {

*I did make another mod also; I set a graphical icon (with the name "bullet") as the default bullet in the "Customize Event Fields" and turned off the bullets in the TEMPLATE setting under the ADMIN.  So now I have a nice bullet for each as default, even if one isn't picked (I didn't like the dots the calendar used for bullets) - but a different bullet can be selected if desired when a new event is added.  Basically all I needed was:

if ($details->{'title'} !~ /.gif/) {

$details->{'title'} = "<img src=http://www.myfilehut.com/userfiles/jeffcocalendar/" . $details->{'icon'} . ".gif border=0>" . $details->{'title'};
}


I did have to add the below lines before the above lines to check the data that I had previously entered, which had no default graphic name, otherwise it showed a blank graphic:

if ($details->{'icon'} eq "")
{
$details->{'icon'} = "bullet" ;
}


It occurred to me also (though I didn't try it) that these changes we've discussed here might lend themselves well if people wanted to add a divider line graphic between events.

------------------

Logged
odysious
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: February 24, 2006, 10:41:00 AM »

I know this is an old post and all but I'm new here and would like to add this functions to the calendar. With all the modification and suggested modification in this post i'm a little confused, what is the proper code to add to the default.html page for this to work?

Thanks

------------------

Logged
Marc
New Member
*

Karma: 0
Offline Offline

Posts: 0

Computer tech


WWW
« Reply #7 on: February 24, 2006, 11:03:00 AM »

I'm using the modifications I made, the last message before your's.

You can see an example at http://calendar.jeffcowebboard.com

------------------

Logged
odysious
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #8 on: February 24, 2006, 11:21:00 AM »

Thanks for the quick reply

If I understand correctly the proper order should be:

if ($details->{'icon'} eq "")
{
$details->{'icon'} = "bullet" ;
}

if ($details->{'title'} !~ /.gif/) {

$details->{'title'} = "<img src=http://www.myfilehut.com/userfiles/jeffcocalendar/" . $details->{'icon'} . ".gif border=0>" . $details->{'title'};
}


Thanks again.

------------------

Logged
Marc
New Member
*

Karma: 0
Offline Offline

Posts: 0

Computer tech


WWW
« Reply #9 on: February 24, 2006, 11:49:00 AM »

Almost, I added a line:

if ($details->{'icon'} eq "")

{
$details->{'icon'} = "bullet" ;
}

if ($details->{'icon'} eq "0")

{
$details->{'icon'} = "bullet" ;
}


if ($details->{'title'} !~ /.gif/) {

$details->{'title'} = "<img src=http://yourimagehosthere/" . $details->{'icon'} . ".gif border=0>" . $details->{'title'};

}

------------------

Logged
odysious
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: February 24, 2006, 11:54:00 AM »

Perfect. Thank you.

------------------

Logged
Foghorn
Guest
« Reply #11 on: March 08, 2006, 08:09:00 PM »

I know this is really old.  But is there a way to do this but have the icon displayed BEFORE the times instead of just the event title?  That would look much better since the calendar displays the time first.

Thanks

Logged
Foghorn
Guest
« Reply #12 on: March 08, 2006, 08:57:00 PM »

I also cannot find where you disable the normal bulleting for the calendar.  I have looked all thought the admin interface.  Where do I find this?

Thanks

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #13 on: March 09, 2006, 01:30:00 AM »

** is there a way to do this but have the icon displayed BEFORE the times instead of just the event title? **

Sure! Place the code in the appropriate place.

** I also cannot find where you disable the normal bulleting for the calendar. **

Calendar Administration-> Template Preferences:
...
- Show Event Times:
- Show Bullets:

** I have looked all thought the admin interface. **

Apparently not.

Dan O.

------------------

Logged
Marc
New Member
*

Karma: 0
Offline Offline

Posts: 0

Computer tech


WWW
« Reply #14 on: March 09, 2006, 07:34:00 AM »

>But is there a way to do this but have the icon displayed BEFORE the times instead of just the event title?

See DanO's answer...

On my calendar I have always had the times turned off so it wasn't a problem when I added the code where it is now.

[This message has been edited by Marc (edited March 09, 2006).]

Logged
Pages: [1] 2   Go Up
Print
Jump to: