igordonin Posted March 26, 2012 Share Posted March 26, 2012 I was talking to some friends, who are just as new as me in programming, and they think it would be better to use a single navigation file for every link in a web site. Something like this: <a href="nav.php?id=home&otherparams" >Home</a> <a href="nav.php?id=products&otherparams" >Products</a> <a href="nav.php?id=contact&otherparams" >Contact</a> I told them I think this might be easier to maintain, but also might take up on loading time, as the site viewer will have to go through an extra node to get where he wants. Is this single navigation file a good practice or should it be avoided? Thanks for any comments... Quote Link to comment https://forums.phpfreaks.com/topic/259771-single-navigation-file/ Share on other sites More sharing options...
kicken Posted March 26, 2012 Share Posted March 26, 2012 A lot of frameworks/cms packages will use a single routing file like that. They typically employ URL re-writing to hide the fact that they do that though. There's nothing wrong with using a single file like that so long as things are structured in a way that it is still easy to maintain the code. A setup like that can be helpful when dealing with initialization code such as for your database connection/session information as well as template control. Quote Link to comment https://forums.phpfreaks.com/topic/259771-single-navigation-file/#findComment-1331384 Share on other sites More sharing options...
Drummin Posted March 27, 2012 Share Posted March 27, 2012 I made a site that all works off the index page and just loads any processing code above html and then content within page, based on page called with Get. I used session to store current page from get and reloaded immediately so, Get's weren't obvious or could be taken advantage of. These were of course checked against valid pages so anyone playing with get values didn't do anything. So basically heading, footer stayed the same and content just changed. Worked out well. "Parts" were stored in different directories based on the name of the pages. Anyway, that's what I did. Quote Link to comment https://forums.phpfreaks.com/topic/259771-single-navigation-file/#findComment-1331396 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.