[PHP] Dynamic menu
Hello All, I am new in this group and first whant to say hello to all. Need me menu who have different link if user is login or logout, something like dynamic menu. Somebody can tall me how can i use and create this menu. Thansk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic menu
On Sat, Jul 17, 2010 at 5:17 PM, jordan jovanovj...@gmail.com wrote: I am new in this group and first whant to say hello to all. Need me menu who have different link if user is login or logout, something like dynamic menu. Somebody can tall me how can i use and create this menu.http://www.php.net/unsub.php Well, your basic logic is: if ( they have a session ) { //output the menu } else { //output the other menu } -- -Dan Joseph http://www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month. Promo Code NEWTHINGS for 10% off initial order -- Reseller Plans also available! http://www.facebook.com/canishosting http://www.facebook.com/originalpoetry
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
-Original Message- From: MEM [mailto:tal...@gmail.com] Sent: terça-feira, 27 de Outubro de 2009 12:05 To: 'a...@ashleysheridan.co.uk' Cc: 'Jim Lucas'; 'php-general@lists.php.net' Subject: RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow Think of it a bit like an online shop selling operating systems: 1) All the main OS's you sell are on the front page - Linux, MacOS Windows 2) User clicks on Linux, and is taken to the url /products/linux and they are shown all the Linux OS's on offer (Fedora, SuSe, Ubuntu, Knoppix, etc) 3) User clicks on Fedora and is taken to the URL /products/linux/fedora and they are shown all the versions of Fedora up to 11 4) etc The URL belies what section you are on, which makes it easy for the user to remember, and easy for you to extract information from to know exactly where the user is. Obviously in the above URLs I'm assuming mod_rewrite is being used. Thanks, Ash http://www.ashleysheridan.co.uk Thanks a lot! Really. I will now start coding based on all this information and see what I will get. I'm sure that the designer will kill me later, by telling me... couldn't we just... fade in this a little bit... Ahhrrggg!!! Regards, Márcio Hello once again, I have take my time to think on this for a while. And I end up on the W3C recommendations about URIs: In a phrase: Keep it semantic, lifetime, and short. Several questions arise at this moment: I was having a url like this: http://www.mysite.com/c_mycontroller/method/1/3/4/54 Where the numbers where Id's of categories or products. Well... this could be as far as we can get from the W3C recommendations. :s So, let's say I short those urls to names, and I remove/hide(?) from the URL the controller and method information's. We could end up on something like this: http://www.mysite.com/categoryname/subcategoryname/subsubcategoryname/productname/ It's more semantic. But what if we have, 4 subcategories for example? This could get quite long. A possible solution to this, is to have something like this: http://www.mysite.com/categoryname/subcategoryname/productname In a way that we always get no more than 3 URI segments. So, if the user navigates to a sub sub sub sub level on the hierarchy, the address could be: http://www.mysite.com/categoryname/subsubsubsubcategoryname/productname 1) What are your thoughts on this? Should I follow this track on your opinions? 2) In order to be semantic, I intend to pass through the URI segments, NOT the Category id's but the Category names. This will bring two issues (at least): 2.1) - I need to query the database, not by ID but by Name. (I'm not sure if they always be unique, I'm not sure if I will have a performance issue). As a note: This is a VERY little website. Nothing too fancy. 2.2) I will grab the categories name from the database, and build the URL with those names, however, some category names will have INVALID chars, like á, ç, spaces... etc... What would be the best way of doing this? Having a new column on the database categories table with a slug field? Or, grab the category name, and prepare that name to be url friendy using a function for that? If it's possible to answer, where on a MVC structure would this function be? Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Tue, 2009-10-27 at 10:25 +, MEM wrote: I think the term drop-menu is bad in this case, as essentially what you are saying is: 1) user is presented with the basic navigation menu 2) user clicks an item and page navigates somewhere else 3) because of the item user clicked in 2) display some extra menu items Exactly. That's not a menu, it's just a navigation bar that changes slightly depending on where you are in the site... Ok... So the focus should not be on the click events, but on the URL changes. Since it will be based on URL changes and not, on click/hover events, I can rely this navigation system entirely on php. Right? If this is correct, the only think I need then, is to create a condition, to show/hide ul/li items based on: a) the url changes. OR b) the existence or non-existence of child array elements that needs to be verified each time the user navigates to a page. Is this correct? Thanks again, Márcio That sounds about right yeah. You could also get a little bit clever and only retrieve the rows from your db that will go to make the array elements you'll need. It doesn't make sense to retrieve a full product list each time someone visits the page, so you only need to retrieve those that the user is interested in, which is shown by what they click on. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
That sounds about right yeah. You could also get a little bit clever and only retrieve the rows from your db that will go to make the array elements you'll need. It doesn't make sense to retrieve a full product list each time someone visits the page, Ok. so you only need to retrieve those that the user is interested in, which is shown by what they click on. The relation between click and the display of the corresponded array child elements, without using js, is the hardest to understand: The user will click on a link / the URL will change / the new page will be loaded to the user / the information displayed on that page should be related with the element clicked on the first step. So, the next page, should know what we have clicked before, in order to display the information accordingly. One of the ways that this can be done, is by passing params over the URL. The URL param will tell us what element have we clicked, so it should be based on URL. Once we have that, we need to ask: as that value passed on the url a correspondent array element that contains children? If so, display them. (I realize my incapacity of talking technically, by referring to pages and other odd entities. I'm sorry for that). Does the above makes any sense? Thanks a lot, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Tue, 2009-10-27 at 11:39 +, MEM wrote: That sounds about right yeah. You could also get a little bit clever and only retrieve the rows from your db that will go to make the array elements you'll need. It doesn't make sense to retrieve a full product list each time someone visits the page, Ok. so you only need to retrieve those that the user is interested in, which is shown by what they click on. The relation between click and the display of the corresponded array child elements, without using js, is the hardest to understand: The user will click on a link / the URL will change / the new page will be loaded to the user / the information displayed on that page should be related with the element clicked on the first step. So, the next page, should know what we have clicked before, in order to display the information accordingly. One of the ways that this can be done, is by passing params over the URL. The URL param will tell us what element have we clicked, so it should be based on URL. Once we have that, we need to ask: as that value passed on the url a correspondent array element that contains children? If so, display them. (I realize my incapacity of talking technically, by referring to pages and other odd entities. I'm sorry for that). Does the above makes any sense? Thanks a lot, Márcio Think of it a bit like an online shop selling operating systems: 1) All the main OS's you sell are on the front page - Linux, MacOS Windows 2) User clicks on Linux, and is taken to the url /products/linux and they are shown all the Linux OS's on offer (Fedora, SuSe, Ubuntu, Knoppix, etc) 3) User clicks on Fedora and is taken to the URL /products/linux/fedora and they are shown all the versions of Fedora up to 11 4) etc The URL belies what section you are on, which makes it easy for the user to remember, and easy for you to extract information from to know exactly where the user is. Obviously in the above URLs I'm assuming mod_rewrite is being used. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
Think of it a bit like an online shop selling operating systems: 1) All the main OS's you sell are on the front page - Linux, MacOS Windows 2) User clicks on Linux, and is taken to the url /products/linux and they are shown all the Linux OS's on offer (Fedora, SuSe, Ubuntu, Knoppix, etc) 3) User clicks on Fedora and is taken to the URL /products/linux/fedora and they are shown all the versions of Fedora up to 11 4) etc The URL belies what section you are on, which makes it easy for the user to remember, and easy for you to extract information from to know exactly where the user is. Obviously in the above URLs I'm assuming mod_rewrite is being used. Thanks, Ash http://www.ashleysheridan.co.uk Thanks a lot! Really. I will now start coding based on all this information and see what I will get. I'm sure that the designer will kill me later, by telling me... couldn't we just... fade in this a little bit... Ahhrrggg!!! Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dynamic menu with show hide capabilities - understanding possible workflow
Hello all, I'm on my way to build my first dynamic menu using php. However, each time I say this, people start jumping at me crying out loud: Jquery . I don't need js for this. Really. (At least, this is what I believe). So I was wondering if It's possible to accomplish it, by using css and php only. If so, I'm wondering if something like this it's a good way for doing this: 1) Generate a multidimensional array from database table containing categories and subcategories. 2) Create a css file with two classes one that shows, another that hides. 3) Grab that array and: 3.1) print it recursively (no idea how to accomplish this) 3.2) print it with some sort of class=showThis inside the generated html element. 3.3) make a conditional somewhere (I really don't know where, and this may be related with the recursion doubt), in order to display the children elements, only when we click the parent element. And here resides my main doubt: Is the point 3.3 feasible without the use of js? I just need some directions please, Regards, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Mon, 2009-10-26 at 13:28 +, MEM wrote: Hello all, I'm on my way to build my first dynamic menu using php. However, each time I say this, people start jumping at me crying out loud: Jquery . I don't need js for this. Really. (At least, this is what I believe). So I was wondering if It's possible to accomplish it, by using css and php only. If so, I'm wondering if something like this it's a good way for doing this: 1) Generate a multidimensional array from database table containing categories and subcategories. 2) Create a css file with two classes one that shows, another that hides. 3) Grab that array and: 3.1) print it recursively (no idea how to accomplish this) 3.2) print it with some sort of class=showThis inside the generated html element. 3.3) make a conditional somewhere (I really don't know where, and this may be related with the recursion doubt), in order to display the children elements, only when we click the parent element. And here resides my main doubt: Is the point 3.3 feasible without the use of js? I just need some directions please, Regards, Márcio Everything there is feasible without Javascript except for the clicking part, which is pretty essential to what you want. Pure CSS-only menus are still unavailable because of IE, so using some Javascript is your only option really. Is there a particular reason you are shying away from Javascript in this case? There are ways you can construct drop-down menus in a way that if Javascript is unavailable, then they fall back to becoming a bog-standard navigation bar. Also, before anyone mentions them, select lists are not the same thing as a drop-down menu, and navigating to different parts of a document upon changing the selected option is actually breaking their default behavior, and can become confusing to people who expect them to work as select lists. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
Thank you all. Ok. Please stay with me, cause I still have some doubts. Not only do I need to display the subitems on click but also, when the user clicks on one menu item, I need to change the URI as well. Why? Because, each time the user clicks on a menu item (whateaver that item as childs or not), I want to display a list of products related to the clicked item. So, I was trying to avoid js, because, I don’t know that much about js. However, I’d like to do it properly, so, the only way I was allowing the use of js, was by do not disabling the back button functionality and by allowing a add to favorites option as well, allowing the URI changing… O.o Anyway, let’s face it: Js is my only option, could this be a nice workflow, for an unobtrusive solution? 1) Generate the multidimensional array from query. 2) Generate the ul / li menu (echo + foreach) displaying all child elements as well. 3) Apply the anchor to the list items. 4) Apply some js to that ul / li that: 4.1) will be responsible for show/hide elements. 4.2) Will be responsible to show/hide elements only when some DOM node(?) as children. 4.3) Change the URI on click, so that some information can be showed based on uri segment. Can I have your help to fill the blanks here, or, if there are to many, just an orientation reference, in order to get started… Thanks a lot once again, Márcio From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: segunda-feira, 26 de Outubro de 2009 14:38 To: MEM Cc: php-general@lists.php.net Subject: Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow On Mon, 2009-10-26 at 13:28 +, MEM wrote: Hello all, I'm on my way to build my first dynamic menu using php. However, each time I say this, people start jumping at me crying out loud: Jquery . I don't need js for this. Really. (At least, this is what I believe). So I was wondering if It's possible to accomplish it, by using css and php only. If so, I'm wondering if something like this it's a good way for doing this: 1) Generate a multidimensional array from database table containing categories and subcategories. 2) Create a css file with two classes one that shows, another that hides. 3) Grab that array and: 3.1) print it recursively (no idea how to accomplish this) 3.2) print it with some sort of class=showThis inside the generated html element. 3.3) make a conditional somewhere (I really don't know where, and this may be related with the recursion doubt), in order to display the children elements, only when we click the parent element. And here resides my main doubt: Is the point 3.3 feasible without the use of js? I just need some directions please, Regards, Márcio Everything there is feasible without Javascript except for the clicking part, which is pretty essential to what you want. Pure CSS-only menus are still unavailable because of IE, so using some Javascript is your only option really. Is there a particular reason you are shying away from Javascript in this case? There are ways you can construct drop-down menus in a way that if Javascript is unavailable, then they fall back to becoming a bog-standard navigation bar. Also, before anyone mentions them, select lists are not the same thing as a drop-down menu, and navigating to different parts of a document upon changing the selected option is actually breaking their default behavior, and can become confusing to people who expect them to work as select lists. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Mon, 2009-10-26 at 15:01 +, MEM wrote: Thank you all. Ok. Please stay with me, cause I still have some doubts. Not only do I need to display the subitems on click but also, when the user clicks on one menu item, I need to change the URI as well. Why? Because, each time the user clicks on a menu item (whateaver that item as childs or not), I want to display a list of products related to the clicked item. So, I was trying to avoid js, because, I don’t know that much about js. However, I’d like to do it properly, so, the only way I was allowing the use of js, was by do not disabling the back button functionality and by allowing a add to favorites option as well, allowing the URI changing… O.o Anyway, let’s face it: Js is my only option, could this be a nice workflow, for an unobtrusive solution? 1) Generate the multidimensional array from query. 2) Generate the ul / li menu (echo + foreach) displaying all child elements as well. 3) Apply the anchor to the list items. 4) Apply some js to that ul / li that: 4.1) will be responsible for show/hide elements. 4.2) Will be responsible to show/hide elements only when some DOM node(?) as children. 4.3) Change the URI on click, so that some information can be showed based on uri segment. Can I have your help to fill the blanks here, or, if there are to many, just an orientation reference, in order to get started… Thanks a lot once again, Márcio From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: segunda-feira, 26 de Outubro de 2009 14:38 To: MEM Cc: php-general@lists.php.net Subject: Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow On Mon, 2009-10-26 at 13:28 +, MEM wrote: Hello all, I'm on my way to build my first dynamic menu using php. However, each time I say this, people start jumping at me crying out loud: Jquery . I don't need js for this. Really. (At least, this is what I believe). So I was wondering if It's possible to accomplish it, by using css and php only. If so, I'm wondering if something like this it's a good way for doing this: 1) Generate a multidimensional array from database table containing categories and subcategories. 2) Create a css file with two classes one that shows, another that hides. 3) Grab that array and: 3.1) print it recursively (no idea how to accomplish this) 3.2) print it with some sort of class=showThis inside the generated html element. 3.3) make a conditional somewhere (I really don't know where, and this may be related with the recursion doubt), in order to display the children elements, only when we click the parent element. And here resides my main doubt: Is the point 3.3 feasible without the use of js? I just need some directions please, Regards, Márcio Everything there is feasible without Javascript except for the clicking part, which is pretty essential to what you want. Pure CSS-only menus are still unavailable because of IE, so using some Javascript is your only option really. Is there a particular reason you are shying away from Javascript in this case? There are ways you can construct drop-down menus in a way that if Javascript is unavailable, then they fall back to becoming a bog-standard navigation bar. Also, before anyone mentions them, select lists are not the same thing as a drop-down menu, and navigating to different parts of a document upon changing the selected option is actually breaking their default behavior, and can become confusing to people who expect them to work as select lists. Thanks, Ash http://www.ashleysheridan.co.uk In that case, what you need to do is navigate to a new URL each time, as there is no way you can change the URL at all. The only way to change it without reloading is to alter the #anchor part of the URL, but that is not too flexible. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
MEM wrote: Thank you all. Ok. Please stay with me, cause I still have some doubts. Not only do I need to display the subitems on click but also, when the user clicks on one menu item, I need to change the URI as well. Why? Because, each time the user clicks on a menu item (whateaver that item as childs or not), I want to display a list of products related to the clicked item. So, I was trying to avoid js, because, I don’t know that much about js. However, I’d like to do it properly, so, the only way I was allowing the use of js, was by do not disabling the back button functionality and by allowing a add to favorites option as well, allowing the URI changing… O.o The JS part isn't for clicking at all. Rather, it is for hovering. Since IE doesn't have hover on any element besides the anchor, it is used to mimic hovering in IE. Use the following example to add the hover ability to your app. http://snipplr.com/view/1912/internet-explorer-ie6-css-hover/ Anyway, let’s face it: Js is my only option, could this be a nice workflow, for an unobtrusive solution? Remember, JS is only used to create the ability for IE to hover over elements :) 1) Generate the multidimensional array from query. 2) Generate the ul / li menu (echo + foreach) displaying all child elements as well. 3) Apply the anchor to the list items. NO!!! don't do the following! 4) Apply some js to that ul / li that: 4.1) will be responsible for show/hide elements. 4.2) Will be responsible to show/hide elements only when some DOM node(?) as children. 4.3) Change the URI on click, so that some information can be showed based on uri segment. Can I have your help to fill the blanks here, or, if there are to many, just an orientation reference, in order to get started… Now to satisfy the people that are going to ask the inevitable question What if JS is turned off?? Show everything by default. Then, using JS, hide all that should be hidden and go from their. Thanks a lot once again, Márcio From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: segunda-feira, 26 de Outubro de 2009 14:38 To: MEM Cc: php-general@lists.php.net Subject: Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow On Mon, 2009-10-26 at 13:28 +, MEM wrote: Hello all, I'm on my way to build my first dynamic menu using php. However, each time I say this, people start jumping at me crying out loud: Jquery . I don't need js for this. Really. (At least, this is what I believe). So I was wondering if It's possible to accomplish it, by using css and php only. If so, I'm wondering if something like this it's a good way for doing this: 1) Generate a multidimensional array from database table containing categories and subcategories. 2) Create a css file with two classes one that shows, another that hides. 3) Grab that array and: 3.1) print it recursively (no idea how to accomplish this) 3.2) print it with some sort of class=showThis inside the generated html element. 3.3) make a conditional somewhere (I really don't know where, and this may be related with the recursion doubt), in order to display the children elements, only when we click the parent element. And here resides my main doubt: Is the point 3.3 feasible without the use of js? I just need some directions please, Regards, Márcio Everything there is feasible without Javascript except for the clicking part, which is pretty essential to what you want. Pure CSS-only menus are still unavailable because of IE, so using some Javascript is your only option really. Is there a particular reason you are shying away from Javascript in this case? There are ways you can construct drop-down menus in a way that if Javascript is unavailable, then they fall back to becoming a bog-standard navigation bar. Also, before anyone mentions them, select lists are not the same thing as a drop-down menu, and navigating to different parts of a document upon changing the selected option is actually breaking their default behavior, and can become confusing to people who expect them to work as select lists. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
On Mon, 2009-10-26 at 08:49 -0700, Jim Lucas wrote: MEM wrote: Thank you all. Ok. Please stay with me, cause I still have some doubts. Not only do I need to display the subitems on click but also, when the user clicks on one menu item, I need to change the URI as well. Why? Because, each time the user clicks on a menu item (whateaver that item as childs or not), I want to display a list of products related to the clicked item. So, I was trying to avoid js, because, I don’t know that much about js. However, I’d like to do it properly, so, the only way I was allowing the use of js, was by do not disabling the back button functionality and by allowing a add to favorites option as well, allowing the URI changing… O.o The JS part isn't for clicking at all. Rather, it is for hovering. Since IE doesn't have hover on any element besides the anchor, it is used to mimic hovering in IE. Use the following example to add the hover ability to your app. http://snipplr.com/view/1912/internet-explorer-ie6-css-hover/ Anyway, let’s face it: Js is my only option, could this be a nice workflow, for an unobtrusive solution? Remember, JS is only used to create the ability for IE to hover over elements :) 1) Generate the multidimensional array from query. 2) Generate the ul / li menu (echo + foreach) displaying all child elements as well. 3) Apply the anchor to the list items. NO!!! don't do the following! 4) Apply some js to that ul / li that: 4.1) will be responsible for show/hide elements. 4.2) Will be responsible to show/hide elements only when some DOM node(?) as children. 4.3) Change the URI on click, so that some information can be showed based on uri segment. Can I have your help to fill the blanks here, or, if there are to many, just an orientation reference, in order to get started… Now to satisfy the people that are going to ask the inevitable question What if JS is turned off?? Show everything by default. Then, using JS, hide all that should be hidden and go from their. Thanks a lot once again, Márcio From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: segunda-feira, 26 de Outubro de 2009 14:38 To: MEM Cc: php-general@lists.php.net Subject: Re: [PHP] dynamic menu with show hide capabilities - understanding possible workflow On Mon, 2009-10-26 at 13:28 +, MEM wrote: Hello all, I'm on my way to build my first dynamic menu using php. However, each time I say this, people start jumping at me crying out loud: Jquery . I don't need js for this. Really. (At least, this is what I believe). So I was wondering if It's possible to accomplish it, by using css and php only. If so, I'm wondering if something like this it's a good way for doing this: 1) Generate a multidimensional array from database table containing categories and subcategories. 2) Create a css file with two classes one that shows, another that hides. 3) Grab that array and: 3.1) print it recursively (no idea how to accomplish this) 3.2) print it with some sort of class=showThis inside the generated html element. 3.3) make a conditional somewhere (I really don't know where, and this may be related with the recursion doubt), in order to display the children elements, only when we click the parent element. And here resides my main doubt: Is the point 3.3 feasible without the use of js? I just need some directions please, Regards, Márcio Everything there is feasible without Javascript except for the clicking part, which is pretty essential to what you want. Pure CSS-only menus are still unavailable because of IE, so using some Javascript is your only option really. Is there a particular reason you are shying away from Javascript in this case? There are ways you can construct drop-down menus in a way that if Javascript is unavailable, then they fall back to becoming a bog-standard navigation bar. Also, before anyone mentions them, select lists are not the same thing as a drop-down menu, and navigating to different parts of a document upon changing the selected option is actually breaking their default behavior, and can become confusing to people who expect them to work as select lists. Thanks, Ash http://www.ashleysheridan.co.uk I've always gone the route of having the drop-downs just accompany a standard, regular, functioning navigation bar. That way, if someone has Javascript turned off, they are still able to use a standard, regular, functioning navigation bar. Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] dynamic menu with show hide capabilities - understanding possible workflow
Thanks a lot for your replies. Let's see if I understand, if not, please, let me know, I'm not that proficient in English. Second try, in order to accomplish this, I have to: 1) Generate the multidimensional array from query. 2) Generate the ul / li menu (echo + foreach) displaying all child elements as well. 3) Apply the anchor to the list items. 3.1) Each anchor on this list should point to a new URL (I don't care if the page refreshes on this case). 4) Print all this on a nice way to the browser. (unobtrusive) 5) Apply js to: 5.1) HIDE the elements that need to be hidden. 5.2) SHOW what needs to be displayed. I don't want to have any onHover effect. The submenus will not appear on a onhover effect. They should appear when the user either clicks on a parent menu item, or navigates to a specific URL. Should this make me change this workflow somehow? Please have patience... :s Thanks again, Márcio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Dynamic menu building
Dear list, I have been facing problems while building dynamic menu. I am using database to store the Menu items. I am having two fields in the database table called ParentID, ChildID. Parent Child 1 0 2 0 3 0 4 1 5 1 6 1 7 3 8 3 9 4 10 8 I want to build menu from this. Please suggest me the way to do so. Thanks in Advance -- Thanks Regards Praveen Kumar SoftPro Systems Ltd ---SOFTPRO DISCLAIMER-- Information contained in this E-MAIL and any attachments are confidential being proprietary to SOFTPRO SYSTEMS is 'privileged' and 'confidential'. If you are not an intended or authorised recipient of this E-MAIL or have received it in error, You are notified that any use, copying or dissemination of the information contained in this E-MAIL in any manner whatsoever is strictly prohibited. Please delete it immediately and notify the sender by E-MAIL. In such a case reading, reproducing, printing or further dissemination of this E-MAIL is strictly prohibited and may be unlawful. SOFTPRO SYSYTEMS does not REPRESENT or WARRANT that an attachment hereto is free from computer viruses or other defects. The opinions expressed in this E-MAIL and any ATTACHEMENTS may be those of the author and are not necessarily those of SOFTPRO SYSTEMS. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Dynamic menu building
Dear list, I have been facing problems while building dynamic menu. I am using database to store the Menu items. I am having two fields in the database table called ParentID, ChildID. ParentChild 10 20 30 41 51 61 73 83 94 108 I want to build menu from this. Please suggest me the way to do so. Thanks in Advance The following will build a two-level menu as an unordered list, with the second level appearing if its parent is selected. The variable $gpid is grandparent id for a third level, which is not displayed in this menu. Some checks are done in order to display a menu item differently if it is the current page or an ancestor of the current page. (In the design I took this example from, third level menus are shown in a different place.) // build menu array $menu_sql = SELECT id, parentid, menuname, FROM pages; $menu_result = mysql_query($menu_sql); if (mysql_num_rows($menu_result) 0) { while ($menu_row = mysql_fetch_array($menu_result)) { $menu_array[] = array($menu_row[id], $menu_row[parentid], $menu_row[menuname]); } } // home id is 10 $id = isset($_GET[id]) ? $_GET[id] : 10; $pid = isset($_GET[pid]) ? $_GET[pid] : 0; $gpid = isset($_GET[gpid]) ? $_GET[gpid] : ; // display menu echo(ul); foreach ($menu_array as $menu) { // if the parent id is 0, menu item is main level if ($menu[1] == 0) { if ($menu[0] == $id || $menu[0] == $pid || $menu[0] == $gpid) { echo(lia class=\selected\ href=\ . $PHP_SELF . ?id= . $menu[0] . amp;pid=0\ . $menu[2] . /a); foreach ($menu_array as $menu2) { if ($menu2[1] == $menu[0]) { $subcount[] = $menu2[1]; } } if (count($subcount) 0) { echo(ul); foreach ($menu_array as $menu3) { if ($menu3[1] == $menu[0]) { if ($menu3[0] == $id || $menu3[0] == $pid) { echo(lia class=\selected\ href=\ . $PHP_SELF . ?id= . $menu3[0] . amp;pid= . $menu3[1] . \ . $menu3[2] . /a/li); } else { echo(lia href=\ . $PHP_SELF . ?id= . $menu3[0] . amp;pid= . $menu3[1] . \ . $menu3[2] . /a/li); } } } echo(/ul); } echo(/li); } else { echo(lia href=\ . $PHP_SELF . ?id= . $menu[0] . amp;pid=0\ . $menu[2] . /a/li); } } } echo(/ul\n); HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic menu not passing value to PHP?
On Tuesday 17 June 2003 05:45, Dennis Martin Ong wrote: Is there something I've missed out cos it seems like the $sltCat which is suppose to pass the selected option value when the form is submitted is not passing the correct value, So have you verified that it passes the value as expected or what? $query_rsCat = SELECT * FROM inventory WHERE category='$sltCat' OR item_name LIKE '%$txtSearch%'; And have you checked that $query_rsCat contains what you expected it to contain? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Sometimes, when I think of what that girl means to me, it's all I can do to keep from telling her. -- Andy Capp */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic menu not passing value to PHP?
Got it sorted out now $query_rsCat = SELECT * FROM inventory WHERE category='$sltCat' OR item_name LIKE '%$txtSearch%'; This will select all the items if either $sltCat or $txtSearch is empty. Janet '%$txtSearch%' would always evaulate as '%%' in Mysql when the txtSearch field is empty thus resulting in Mysql selecting everything in the database making the the category='$sltCat' redundant... I've rewritten it as: if(empty($txtSearch)){ $query_rsCat= SELECT * FROM inventory WHERE category='$sltCat'; } else { $query_rsCat=SELECT * FROM inventory WHERE item_name LIKE '%$txtSearch%'; } to circumvent this and it worked.. Thanks Janet for pointing this out...and thanks all for the help Dennis Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tuesday 17 June 2003 05:45, Dennis Martin Ong wrote: Is there something I've missed out cos it seems like the $sltCat which is suppose to pass the selected option value when the form is submitted is not passing the correct value, So have you verified that it passes the value as expected or what? $query_rsCat = SELECT * FROM inventory WHERE category='$sltCat' OR item_name LIKE '%$txtSearch%'; And have you checked that $query_rsCat contains what you expected it to contain? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Sometimes, when I think of what that girl means to me, it's all I can do to keep from telling her. -- Andy Capp */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic menu not passing value to PHP?
Hi, I'm trying to create a page where a user can choose to view products by category by selecting a drop down menu or he can choose to do a search against the item name. The script seems to work but I'm puzzled cos the mysql query seems to be querying all the category while it is suppose to match it via the selected option value from the dynamic menu. Is there something I've missed out cos it seems like the $sltCat which is suppose to pass the selected option value when the form is submitted is not passing the correct value, resulting in the mysql query throwing out all the info when it is supposed to only throw info when category match $sltCat.. Thanks in advance for the help Dennis ?php require_once('Connections/connPyramid.php'); ? ?php mysql_select_db($database_connPyramid, $connPyramid); $query_rsMenu = SELECT category FROM category ORDER BY category ASC; $rsMenu = mysql_query($query_rsMenu, $connPyramid) or die(mysql_error()); $row_rsMenu = mysql_fetch_assoc($rsMenu); $totalRows_rsMenu = mysql_num_rows($rsMenu); $maxRows_rsCat = 10; $pageNum_rsCat = 0; if (isset($HTTP_GET_VARS['pageNum_rsCat'])) { $pageNum_rsCat = $HTTP_GET_VARS['pageNum_rsCat']; } $startRow_rsCat = $pageNum_rsCat * $maxRows_rsCat; mysql_select_db($database_connPyramid, $connPyramid); $query_rsCat = SELECT * FROM inventory WHERE category='$sltCat' OR item_name LIKE '%$txtSearch%'; $query_limit_rsCat = sprintf(%s LIMIT %d, %d, $query_rsCat, $startRow_rsCat, $maxRows_rsCat); $rsCat = mysql_query($query_limit_rsCat, $connPyramid) or die(mysql_error()); $row_rsCat = mysql_fetch_assoc($rsCat); if (isset($HTTP_GET_VARS['totalRows_rsCat'])) { $totalRows_rsCat = $HTTP_GET_VARS['totalRows_rsCat']; } else { $all_rsCat = mysql_query($query_rsCat); $totalRows_rsCat = mysql_num_rows($all_rsCat); } $totalPages_rsCat = ceil($totalRows_rsCat/$maxRows_rsCat)-1; ? form name=frmProducts method=post action=products.php select name=sltCat id=select value option value=NoneNone/option ?php do { ? option value=?php echo $row_rsMenu['category']??php echo $row_rsMenu['category']?/option ?php } while ($row_rsMenu = mysql_fetch_assoc($rsMenu)); $rows = mysql_num_rows($rsMenu); if($rows 0) { mysql_data_seek($rsMenu, 0); $row_rsMenu = mysql_fetch_assoc($rsMenu); } ? /select input type=text name=txtSearch input type=submit name=btnGo value=Go... ?php do { ? ?php echo ($row_rsCat['item_name']); ? ?php } while ($row_rsCat = mysql_fetch_assoc($rsCat)); ? /form ?php mysql_free_result($rsMenu); mysql_free_result($rsCat); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic menu from DB
Hi all, I'm making a new site for a client and he needs to put several different menus under a static FLASH menu. The bad part is that every item in the flash menu leads to different categories and these need different number of sub menus. I use MySQL PHP 4. The categories and sub categories are something like this: * Products -- Flash static menu - Item 1 -- MySQL fetched menu - Item 2 -- MySQL fetched menu - Item 3 -- MySQL fetched menu - Item 3-1 -- MySQL fetched menu - Item 3-2 -- MySQL fetched menu * Services -- Flash static menu - Item 1 -- MySQL fetched menu - Item 1-1 -- MySQL fetched menu - Item 1-2 -- MySQL fetched menu - Item 2 -- MySQL fetched menu - Item 3 -- MySQL fetched menu What would be the best solution for this? Another problem to solve is the creation of new children into the menu... sub categories AND items dynamically. Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic menu from DB
I don't know about the flash part, but submenus are simple. Your menu items table needs a parent column, where the id of the parent menu item, but for top level menus (Flash static menu) it will be 0. Then first select all menu items with parent=0 and as you loop throught the result result, recursively get all child elements. This function will get you started: get_childs($menu_id) { $resp=array(); $res=mysql_query(SELECT * FROM menu_items WHERE menu_parent_id='$menu_id'); if(mysql_num_rows($res)) { for($i=0;$tmp=mysql_fetch_array($res); $i++) { $resp[$i]['menu']=$tmp; // ['menu'] will contain info about particular menu item $resp[$i]['childs']=get_childs($tmp['menu_id']); // ['menu'] will contain all childs of this menu items, each child will again contain ['menu'] and ['childs'] etc. } } return $resp; } $menu_tree = get_childs(0); echo 'pre'; print_r($menu_tree); echo '/pre'; Cesar Aracena wrote: Hi all, I'm making a new site for a client and he needs to put several different menus under a static FLASH menu. The bad part is that every item in the flash menu leads to different categories and these need different number of sub menus. I use MySQL PHP 4. The categories and sub categories are something like this: * Products -- Flash static menu - Item 1 -- MySQL fetched menu - Item 2 -- MySQL fetched menu - Item 3 -- MySQL fetched menu - Item 3-1 -- MySQL fetched menu - Item 3-2 -- MySQL fetched menu * Services -- Flash static menu - Item 1 -- MySQL fetched menu - Item 1-1 -- MySQL fetched menu - Item 1-2 -- MySQL fetched menu - Item 2 -- MySQL fetched menu - Item 3 -- MySQL fetched menu What would be the best solution for this? Another problem to solve is the creation of new children into the menu... sub categories AND items dynamically. Thanks in advance, Cesar L. Aracena [EMAIL PROTECTED] [EMAIL PROTECTED] (0299) 156-356688 Neuquén (8300) Capital Argentina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic menu possible?
Whell, you could use that php script for getting file names and put links toward those files in a layer, which can be controled with java. If you are not a java expert, you can do it with macromedia dreamweaver + extensions. I don't know java, but I made a layer based site at http://www.okspartak.f2s.com/moj/ The best thing is that extensions are free ! If you are not sure in the number of files, you can use those ext. to make a scrollable meny, which can be a very attractive detail. Cheers Nikola 9/16/01 4:24:22 PM, LRW [EMAIL PROTECTED] wrote: Hi all. I was wondering if a situation I'll describe below is possible. If it is, I'm hoping someone could point me to the topics I would need to study to learn how to do it. I hate to say that right now I don't have the time to read the Manual or any books cover-to-cover to figure it out...but I do want to learn how to do things on my own. So if someone could just tell me what the items I'd need to study are called, I'd really appreciate it. What I want to do is have a drop-down menu where the options are files located in a folder on the server that changes as items are added to or removed. Then the user can select an item from the menu, submit, and that page will load. Did that make sense? So I have 1.htm and 2.htm and 3.htm in a folder. A selectable menu reads the folder and lists those three files as options. The user can click on it and submit and that page will load. And if I add 4.htm, the menu will add that to the drop down on its own. That that's not possible, how close can I get to something like that? An example of something close to that I found on www.megatokyo.com . They have a dropdown menu where a user selects an item and gets sent to that page. A URL from one attempts shows as http://www.megatokyo.com/index.php?date=2001-09-04 . How is that done? Again, if I could just be pointed to the related PHP concepts I'll take it from there. Thanks! Liam www.celticbear.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] dynamic menu possible?
Your wanted solution is seen in the "phpXML" demo, by Michael P. Mehl. It is founded at the http://www.phpxml.org/. Try the exciting "xpath" example! -Original Message- From: LRW [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 16, 2001 4:24 PM To: [EMAIL PROTECTED] Subject: [PHP] dynamic menu possible? Hi all. I was wondering if a situation I'll describe below is possible. If it is, I'm hoping someone could point me to the topics I would need to study to learn how to do it. I hate to say that right now I don't have the time to read the Manual or any books cover-to-cover to figure it out...but I do want to learn how to do things on my own. So if someone could just tell me what the items I'd need to study are called, I'd really appreciate it. What I want to do is have a drop-down menu where the options are files located in a folder on the server that changes as items are added to or removed. Then the user can select an item from the menu, submit, and that page will load. Did that make sense? So I have 1.htm and 2.htm and 3.htm in a folder. A selectable menu reads the folder and lists those three files as options. The user can click on it and submit and that page will load. And if I add 4.htm, the menu will add that to the drop down on its own. That that's not possible, how close can I get to something like that? An example of something close to that I found on www.megatokyo.com . They have a dropdown menu where a user selects an item and gets sent to that page. A URL from one attempts shows as http://www.megatokyo.com/index.php?date=2001-09-04 . How is that done? Again, if I could just be pointed to the related PHP concepts I'll take it from there. Thanks! Liam www.celticbear.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] dynamic menu possible?
Hi all. I was wondering if a situation I'll describe below is possible. If it is, I'm hoping someone could point me to the topics I would need to study to learn how to do it. I hate to say that right now I don't have the time to read the Manual or any books cover-to-cover to figure it out...but I do want to learn how to do things on my own. So if someone could just tell me what the items I'd need to study are called, I'd really appreciate it. What I want to do is have a drop-down menu where the options are files located in a folder on the server that changes as items are added to or removed. Then the user can select an item from the menu, submit, and that page will load. Did that make sense? So I have 1.htm and 2.htm and 3.htm in a folder. A selectable menu reads the folder and lists those three files as options. The user can click on it and submit and that page will load. And if I add 4.htm, the menu will add that to the drop down on its own. That that's not possible, how close can I get to something like that? An example of something close to that I found on www.megatokyo.com . They have a dropdown menu where a user selects an item and gets sent to that page. A URL from one attempts shows as http://www.megatokyo.com/index.php?date=2001-09-04 . How is that done? Again, if I could just be pointed to the related PHP concepts I'll take it from there. Thanks! Liam www.celticbear.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]