Jump to content

Using Sitemap/Folder Structure to Navigate Through Site


millsy007

Recommended Posts

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?

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.