Jump to content

Dynamic Nav Advice


mattm100

Recommended Posts

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,

Link to comment
Share on other sites

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 by Jessica
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.