Malevolence Posted March 13, 2009 Share Posted March 13, 2009 Hi! Have been doing some web design/developing for some people, just need some pointers on how I can rearrange the tasks of the initial entry of an url, to the resulting page with all of the dynamic data in place, including the nav bar (which is dynamic based on pages that are flagged to display in the nav bar), the sidebar (same as before), and the content retrieved from a MySQL database where the last part of the URI matches the 'aURI' field of that table. It's a lot of processing, but takes place fairly quicky. Here's what it's like: URL Entry (e.g. www.randomsite.com/articles/test) 404 Error is returned, 404 page = index.php index.php handles the URI. It also fetches some page defaults from a DB table Require articles.inc.php (in this example) - Send 200 OK Header to Browser Grab the 'test' article from DB by aURI field If not returned, return /404 and exit If flagged as draft, return /404 and exit (or 403 perhaps) Display page ...Display data from DB relative to article [*] ...Display sidebar (content based on page type, e.g. page or article) [*] ...Display navbar (content based on all the flags from every page exploded by commas and display the buttons for the pages that have the correct flag set to 1 and don't display those that are set to 0) I dunno if I was exact but its a lot of processes to carry out. Perhaps I could collage database queries into one big query, but that's not using MySQL to it's full potential, as some will say- php is better to just process data that MySQL can't, but this cannot always be done. NB: When I refer to 'flags', I mean a field in the table of the database that has various flags for settings. They have a couple of purposes, for example the first three are: {num} draft? , {num} display in navbar? , {num} display in sidebar? , {num} display in search results? so it would look like this in a DB entry: 0,1,1,1 - these would then need to be exploded into an array where the data could then be processed. Don't worry about how I'm going to change singular flags in the Control Panel as I will just write it so that they implode back together using a comma as the delimiter... simple. Hope you guys can help me out. If you think my 'clean URL' method sucks, perhaps you can suggest a better & more optimised approach. Mod_rewrite was returning 500 errors despite being perfect syntax followed from tutorials and my own knowledge... the 404 redirect method is good because no matter what is typed in, index.php is in control. If a page exists, then it will require the correct file and send a 200 OK to the browser. Thanks in advance, Dan. Link to comment https://forums.phpfreaks.com/topic/149326-optimising-an-arduous-list-of-processes/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.