Foros del Web » Programando para Internet » PHP »

Ayuda

Estas en el tema de Ayuda en el foro de PHP en Foros del Web. Hola a todos. Podrían ayudarme con esto: lo que expongo es un código que me crea un menú y está hecho en javascript, ahora quisiera ...
  #1 (permalink)  
Antiguo 26/04/2004, 09:51
 
Fecha de Ingreso: febrero-2004
Ubicación: Guayaquil
Mensajes: 110
Antigüedad: 13 años, 9 meses
Puntos: 0
Ayuda

Hola a todos.

Podrían ayudarme con esto:
lo que expongo es un código que me crea un menú y está hecho en javascript, ahora quisiera saber si lo podría colocar dentro de código php??, ya que deseo que los menúes y submenúes que se presentan, se hagan de manera dinámica, sacando los mismos de una tabla de la DB, lo menúes los coloco de rojo





Switch menu 2, stuff that happens before the menus are moved down again.
************************************************** ******************************/
function swmenu2(num,snum){
isthere=0;
sisthere=0;
if(active>-1 && snum==-1){
//Hiding submenus
for(j=0;j<oSlide[active].subs;j++){oSlide[active].sub[j].hideIt()}
oSlide[active].bgImg(level0_regular)
oSlide[active].moveIt(0,oSlide[active].starty)
}
if(sactive>-1){
//Hiding submenus
for(j=0;j<oSlide[active][sactive].sub.length;j++){oSlide[active][sactive].sub[j].hideIt()}
oSlide[active].sub[sactive].bgImg(oSlide[active].sub[sactive].origimg)
oSlide[active].sub[sactive].moveIt(10,oSlide[active].sub[sactive].starty)
//Move back to place
for(i=sactive+1;i<oSlide[active].sub.length;i++){
oSlide[active].sub[i].moveIt(oSlide[active].sub[i].x,oSlide[active].sub[i].starty)
}
}
active=num
//Showing submenus
if(snum>-1){
sactive=snum
for(j=0;j<oSlide[num][snum].sub.length;j++){oSlide[num][snum].sub[j].showIt()}
oSlide[num].sub[snum].moveBy(10,3)
oSlide[num].sub[snum].bgImg(level1_round2)
}else{
sactive=-1
for(j=0;j<oSlide[active].subs;j++){oSlide[active].sub[j].showIt()}
oSlide[num].moveBy(10,3)
oSlide[num].bgImg(level0_round)
}
if(num!=oSlide.length-1) moveDown(num,snum)
else{
isthere=num
moveDown(num,snum)
}
}
/************************************************** ******************************
Moving the menus down
************************************************** ******************************/
function moveDown(num,snum){
//if(num==oSlide.length-1) isthere=num
for(i=num+1;i<oSlide.length;i++){
if(snum==-1){
if(oSlide[i].y<(oSlide[num].subs-1)*subheight+oSlide[i].starty+between-pxspeed) oSlide[i].moveBy(0,pxspeed)
else{oSlide[i].moveIt(oSlide[i].x,(oSlide[num].subs-1)*subheight+oSlide[i].starty+between); isthere=i}
}else{
if(oSlide[i].y<(oSlide[num].subs-1)*subheight+oSlide[i].starty+between-pxspeed + (oSlide[num][snum].subs-1)*subheight+between) oSlide[i].moveBy(0,pxspeed)
else{oSlide[i].moveIt(oSlide[i].x,(oSlide[num].subs-1)*subheight+oSlide[i].starty+between + (oSlide[num][snum].subs-1)*subheight+between); isthere=i}
}
}
if(snum!=-1){
for(i=snum+1;i<oSlide[num].sub.length;i++){
if(oSlide[num].sub[i].y<(oSlide[num][snum].subs-1)*subheight+oSlide[num].sub[i].starty+between-pxspeed) oSlide[num].sub[i].moveBy(0,pxspeed)
else{oSlide[num].sub[i].moveIt(oSlide[num].sub[i].x,(oSlide[num][snum].subs-1)*subheight+oSlide[num].sub[i].starty+between); sisthere=i}
}
}
if(snum==-1){
if(isthere<oSlide.length-1) setTimeout("moveDown("+num+","+snum+")",timspeed)
else going=false
}else{
if(isthere<oSlide.length-1 || (sisthere<oSlide[num].sub.length-1 && snum!=oSlide[num].sub.length-1)) setTimeout("moveDown("+num+","+snum+")",timspeed)
else going=false
}
}
var test=0
/************************************************** ******************************
Functions to write out the layers...
************************************************** ******************************/
menus=new Array(); var a=0; var b=0; var c=0; var d=0
function makeMenu(type,text,lnk,target,end){
str=""; tg="";
if(target) tg='target="'+target+'"'
if(!lnk) lnk="#"
self.status=lnk
if(a==0) str='<div id="divSlideCont">\n'
if(type=="top"){
menus[a]=new Array();
if(text=="seperator"){
str+='\t<div id="divSlide'+a+'" class="clSlide"></div>\n'
menus[a].seperator=1
}else{
str+='\t<div id="divSlide'+a+'" class="clSlide"><a href="'+lnk+'" '+tg+' onclick="swmenu('+a+',-1,-1); if(bw.ie || bw.ns6) this.blur(); '
if(lnk=="#") str+='return false'
str+='" class="clSlideLinks"> '+text+'</a><br></div>\n'
}
menus[a].subs=0; a++; b=0
}else if(type=="sub"){
str+='\t\t<div id="divSlideSub'+(a-1)+'_'+(b)+'" class="clSlideSub"><a '+tg+' onclick="swmenu('+(a-1)+','+b+',-1); if(bw.ie || bw.ns6) this.blur(); '
if(lnk=="#") str+='return false'
str+='" href="'+lnk+'" class="clSlideSubLinks"> '+text+'</a><br></div>\n'
b++; menus[a-1].subs=b; menus[a-1][b-1]=new Array(); c=0; menus[a-1][b-1].subs=0
}else if(type=="sub2"){
str+='\t\t<div id="divSlideSub'+(a-1)+'_'+(b-1)+'_'+c+'" class="clSlideSub2"><a '+tg+' href="'+lnk+'" class="clSlideSub2Links"> '+text+'</a><br></div>\n'
c++; menus[a-1][b-1].subs=c; menus[a-1][b-1][c-1]=new Array(); d=0; menus[a-1][b-1][c-1].subs=0
}
if(end) str+="</div>"
document.write(str)
}
function preLoadBackgrounds(){
for(i=0;i<arguments.length;i++){
this[i]=new Image()
this[i].src=arguments[i]
}
return this
}
</script>
</head>

<body bgcolor="#FFFFFF">
<script>

//Variables to set
between=28 //The pixel between the menus and the submenus
mainheight=25 //The height of the mainmenus
subheight=22 //The height of the submenus
pxspeed=13 //The pixel speed of the animation
timspeed=15 //The timer speed of the animation
menuy=80 //The top placement of the menu.
menux=0 //The left placement of the menu
//Images - Play with these
level0_regular="level0_regular.gif"
level0_round="level0_round.gif"
level1_regular="level1_regular.gif"
level1_round="level1_round.gif"
level1_sub="level1_sub.gif"
level1_sub_round="level1_sub_round.gif"
level1_round2="level1_round2.gif"
level2_regular="level2_regular.gif"
level2_round="level2_round.gif"

//Leave this line
preLoadBackgrounds(level0_regular,level0_round,lev el1_regular,level1_round,level1_sub,level1_sub_rou nd,level1_round2,level2_regular,level2_round)


//There are 3 different types of menus you can make
//top = Main menus
//sub = Sub menus
//sub2 = SubSub menus

//You control the look of the menus in the stylesheet

//makeMenu('TYPE','TEXT','LINK','TARGET', 'END (THE LAST MENU)')

//Menu 0
makeMenu('top','Noticias')
makeMenu('sub','Newest news','/news/index.asp')
makeMenu('sub','News archive','/news/archive.asp')

//Menu 1
makeMenu('top','Scripts')
makeMenu('sub','New scripts','/script/search.asp?new=1')
makeMenu('sub','All scripts','/script/index.asp')
makeMenu('sub','Categories')
makeMenu('sub2','Menu scripts','/script/search.asp?category=menu')
makeMenu('sub2','Text scripts','/script/search.asp?category=text')
makeMenu('sub2','Animation scripts','/script/search.asp?category=animation')
makeMenu('sub2','Other scripts','/script/search.asp?category=other')

//Menu 2
makeMenu('top','Tutoriales')
makeMenu('sub','Tutorials','/tutorials/index.asp')
//Menu 3
makeMenu('top','Forums')
makeMenu('sub','Cool sites','forums/forum.asp?FORUM_ID=1&CAT_ID=1&Forum_Title=Cool+sit es')
makeMenu('sub','CoolMenus','forums/forum.asp?FORUM_ID=2&CAT_ID=1&Forum_Title=CoolMenu s')
makeMenu('sub','Crossbrowser','forums/forum.asp?FORUM_ID=3&CAT_ID=1&Forum_Title=Crossbro wser+DHTML')
makeMenu('sub','Scripts','forums/forum.asp?FORUM_ID=4&CAT_ID=1&Forum_Title=DHTML+Sc ripts')
makeMenu('sub','dhtmlcentral.com','forums/forum.asp?FORUM_ID=5&CAT_ID=1&Forum_Title=dhtmlcen tral%2Ecom')
makeMenu('sub','General','forums/forum.asp?FORUM_ID=6&CAT_ID=1&Forum_Title=General+ DHTML+issues')
makeMenu('sub','Off-topic','forums/forum.asp?FORUM_ID=9&CAT_ID=1&Forum_Title=Off%2Dto pic')
makeMenu('sub','Active topics','forums/active.asp')

//Menu 4
makeMenu('top','CoolMenus')
makeMenu('sub','Examples','coolmenus/examples/')
makeMenu('sub','Download','coolmenus/download.asp')
makeMenu('sub','Tutorial','coolmenus/tutorial.asp')
makeMenu('sub','FAQ','faq/index.asp')

//Menu 5
makeMenu('top','Resources')
makeMenu('sub','DHTML Links','resources/default.asp')

//Menu 6
makeMenu('top','dhtmlcentral')
makeMenu('sub','dhtmlcentral','dhtmlcentral/index.asp',"",1)

//Starting the menu
onload=SlideMenuInit;
</script>

</body>
</html>
makeMenu('top','Noticias') makeMenu('sub','Newest news','/news/index.asp') makeMenu('sub','News archive','/news/archive.asp') makeMenu('top','Noticias') makeMenu('sub','Newest news','/news/index.asp') makeMenu('sub','News archive','/news/archive.asp')
  #2 (permalink)  
Antiguo 26/04/2004, 10:19
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 15 años, 11 meses
Puntos: 126
Habría que ver como estructuras tus menus en tu Base de datos ..por qué en función de como los almacenes en tu BD y la gerarquía que le des .. así tendras que llamar a las porciones de código Javascript que indican que se ha de crear una rama o sub-rama de ese menú.

Y para esto . debes conocer bien que hace dicho código javacript y como organiza sus menús ...

Recuerda que PHP "genera" tu HTML/javascript/salida en general dependiendo de tu lógica (programación) ..

Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:29.