mattm100 Posted February 19, 2013 Share Posted February 19, 2013 Hello Everyone, I am improving the catalogue website that I built not so long ago, trying to make it more dynamic and I have found many of the answers that I'm looking for from Google and PHPfreaks but would like to get some answers and opinions specific to me. I am having some issues with the navigation. Currently the navigation is not dynamic (the product pages are linked to mySQL tables, which lists them but it is nowhere near where I would like it to be) I am not using a txt file or a table specific to the navigation, I am thinking of using my exisiting 'Room' table (RoomID, RoomName) to list the links I want. Should I also add a column that lists the directory to the desired page, so I would use one variable for the link text then one for the actual link. My next question is when I am on a room page (/products/bedroom), how do I then add a sub menu on that page to list sub directorys without manually entering the RoomID like "SELECT * FROM furnituretype WHERE roomid = 1" (I have a seperate table for the type of furniture, for instance 1= Wardrobes, 2 = Bedsides, etc). I was thinking I could use a POST but again I am not sure that would be the right way to go. Am I able to take it from the directory that I am in? I have found 'basename($_SERVER['PHP_SELF']);' but that lists index.php. Any help would be great, I am not looking to be spoon fed (it may look that way) but some advice. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/ Share on other sites More sharing options...
Jessica Posted February 19, 2013 Share Posted February 19, 2013 (edited) You shouldn't even have a separate page for each Room unless there are actually significant differences in what you display for each room (ie, does each room display a list of products? That's one PHP file.) To answer the question you would use URL rewriting (mod_rewrite) to get the parameters onto the query string and use $_GET. A basic URL would look like room.php?room=bedroom And you'd have your URL be room/bedroom And use mod_rewrite to get it to show room.php?room=bedroom to PHP. Then your file would do $room = $_GET['room']; and go from there. Edited February 19, 2013 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1413420 Share on other sites More sharing options...
mattm100 Posted February 19, 2013 Author Share Posted February 19, 2013 The catalogue is for a small furniture shop, each room has multiple different sub categories and each have multiple attributes they can narrow down (style, colour, material, etc). Bedroom (10 sub categories) Garden (4) Living Room (5) DIning Room (4) Office (4) Using mod rewrite would it work the opposite way so that once clicking the bedroom link it would direct to products/bedroom/ ? I ask because as the their search goes deeper links like 'room.php?roomid=bedroom?typeid=wardrobe?style=SantaFe' are getting quite ugly. I'd like the pages to be shown like: products/bedroom/wardrobes or products/diningroom/diningtables then if they wanted to narrow down their search 'products/bedroom/wardrobes.php?style=santafe' would be fine. (That may not be correct as I have index files in the room folders.) Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1413493 Share on other sites More sharing options...
Jessica Posted February 19, 2013 Share Posted February 19, 2013 That is what mod_rewrite does. You really shouldn't have folders for each room. You could do all of that with ONE php file, and a database. The subcategories, attributes, etc should all be stored in the DB. Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1413494 Share on other sites More sharing options...
mattm100 Posted February 19, 2013 Author Share Posted February 19, 2013 Ok, I got mixed up then, I thought that the links would be shown as room.php?roomid=bedroom in the browers rather than the other way around. So your saying it should be built around a single webpage? Would I then use if statements to include different php files for the different layout between the product page to the homepage? The attributes and the catagories are stored in tables. I will do more research on this in the morning. Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1413501 Share on other sites More sharing options...
Jessica Posted February 19, 2013 Share Posted February 19, 2013 Not the entire website, but the products pages. If the only difference between the two folders is they have different subcategories and attributes which you already store in a folder, what could possibly be different in the PHP files for each? Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1413502 Share on other sites More sharing options...
mattm100 Posted February 19, 2013 Author Share Posted February 19, 2013 You are dead right, the only difference between them (code wise) is that they each select different rooms. They use exactly the same code other than hard coded variable. The reason why I did it this way was to give structure to the website as I had no clue about mod_rewrite and didn't want the address ending up like 'room.php?roomid=bedroom?typeid=wardrobe?style=SantaFe'. Thank you for your help so far, you've cleared it up for me and I can get reworking it. Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1413525 Share on other sites More sharing options...
mattm100 Posted February 23, 2013 Author Share Posted February 23, 2013 Well that mod_rewrite looks about as fun as being kicked in the unmentionables, I have been looking into it but the only problem is that my current hosting is a shared package and the hosting service does not allow direct access to the httpd.conf file. I have spoken to the support service and they say that I can do similar with htaccess file, I am not sure of this as I thought that could be used for redirecting pages and thats not what I am trying to do. mod_rewrite is enabled on the servers so I have been told that I can use scripts to do the job but again I am not sure. Quote Link to comment https://forums.phpfreaks.com/topic/274688-dynamic-nav-advice/#findComment-1414414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.