Hello all
I need to find a solution to a problem. Any suggestions will be considered and I will try and keep this very simple!
I have a table (tblpages) which essentially stores every page in a website and the user can create new pages or edit pages via the CMS.
Each record consists of a number of different fields but the most important are:
ID, NAME, URL, CONTENT, HTMLTITLE, KEYWORDS, DESCRIPTION, PARENTID
The records can be children of other records thus allowing me to create a multi-level relationship between menu items on my site storing the ID of a record within the PARENTID field of another record.
When a page is updated via the CMS by a user, I create a "friendly URL" which is based on the NAME field e.g. "About Us" is stored as "about-us". I think this is a very typical setup that I hope many of you can relate to.
The issue I have is when a client creates multiple pages which have the same name (and therefore URL) but ofcourse has different content and META data.
My current function to obtain data from the database is based on getting the last part of the URL where I then query the database using that very string.
A typical URL would be:
/about-us/sub-page-1/sub-page-2
I would then query the database WHERE URL = 'sub-page-2'
But I could also have this page:
/services/sub-service-1/sub-page-2
Therefore my query is finding two records that have the URL field as "sub-page-2" but returns the last one in the looped recordset which might not be the correct data!
Can anyone suggest a solution to help me overcome this problem?
Many Thanks for reading my post.