millsy007 Posted November 25, 2008 Share Posted November 25, 2008 I would like to set up some navigation similar to that used on many blog sites where the user will have the option at the top of the page of 'previous' 'next' and 'home' for my pages. My issue is that I would not want to hard code in the next and previous pages within the site, but would instead it like to work automatically by working off either the sitemap or the folder structure of the website to workout what the next page within this stucture was and link to that. Any ideas or examples where this has been done? Link to comment https://forums.phpfreaks.com/topic/134186-using-sitemapfolder-structure-to-navigate-through-site/ Share on other sites More sharing options...
simonrs Posted November 25, 2008 Share Posted November 25, 2008 Well first thing is that you should be able to "hard code" the "home" link. Blog sites will do this typically by associating a database id with each blog post. Obviously the page knows the id of the page currently being viewed, then its just a case of incrementing/decrementing it for the previous/next. Safer would be to do two database queries on your blog database table: one where the id has to be less than the current post, ordered by id ASC, limit 1 - the returned row will have the id of previous (if there is one - as the first post may be being displayed). Likewise a similar query could get the id of the next post. Link to comment https://forums.phpfreaks.com/topic/134186-using-sitemapfolder-structure-to-navigate-through-site/#findComment-698502 Share on other sites More sharing options...
millsy007 Posted November 25, 2008 Author Share Posted November 25, 2008 The problem is my site has not been set up as most blog sites, ie the pages are not stored within a database with IDs. They are however saved hierarchically within the sitemap so I was hoping to use this as the basis for the previous / next navigation? Could php read the sitemap xml file and navigate though this? Link to comment https://forums.phpfreaks.com/topic/134186-using-sitemapfolder-structure-to-navigate-through-site/#findComment-698530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.