Is it possible to get the menu to show a 'new' item?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Is it possible to get the menu to show a 'new' item?

Post by Ruth »

I was wondering if there's a code where you can put in a 'new' with a date expiration on it for when a new item in put on a website? I mean to get that to function in the menu. Say I put up a new poem and want the 'poetry' link to show new next to it for 15 days or so. Thanks,

Ruth
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

You need a backend built like php, perl, or asp to add menu items.
I wouldn't attempt it myself.

Regards
maz
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Maz, I'm not sure what you're saying, and I think I didn't say clearly what I meant, it's not about adding menu items, it's about putting a code that shows it as a new item that then expires at a certain date. Here's a code I found at Dynamic Drive

Description: This is a very practical script that allows you to display a "what's new" image beside new content for a certain amount of time, then disappear automatically when the time expires.

Directions

Step 1: Insert the below into the <head> section of your page:

Code: Select all

<script>
<!--
/*
"Whats new?" image script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

//set the below to the image you wish to use as the "new" image
var imagetag='<img src="wahtever.gif">'
var today=new Date()
function expireat(expiredate){
var expire=new Date(expiredate)
if (today.getTime()<=expire.getTime())
document.write(imagetag)
}
//-->
</script>
_________

Step 2: Add the below code alongside the "new" content. By doing so, a "what's new" image will show up until the specified date in function "expireat()":

Code: Select all

<script>
expireat("November 21, 2001")
</script>
I've found a couple of other different js codes that are supposed to do that, and I am wondering if it's possible to implement one of them with the menu.

Ruth
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

I think what you are looking for is something like this

Code: Select all

var expiredate = new Date("September 22, 2003")
var today=new Date()

if(today<=expiredate)aI("text=Menu Item Goes Here");

This can go inside the menu definition.

Lots funky stuff like that if you need it

Cheers
Andy
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Thanks Andy. I'll play with it and come back if I can't figure it out. Glad you got the power back. :)

Ruth
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Yeah Andy, its nice havin ya on the forums again. Welcome back.

To build upon what Andy said, which was display an entire menu item when the dates are right, you could just set an img variable which would be a new image icon.

Code: Select all

now = new Date();

newimg = ( now<=new Date("9/25/2003") ) ? "<img src='newimage.gif'>" : "";
aI("text="+newimg+" Menu 1");    newimg="";

newimg = ( now<=new Date("9/23/2003") ) ? "<img src='newimage.gif'>" : "";
aI("text="+newimg+" Menu 2");    newimg="";

Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Post Reply