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