I’m working on a CMS system that receives urls like this:
/parent1/parent2/child/
Now it’s easy to check only the child but in my opinion you should also check if the parents are correct and in the right order. The problem is that I’m unsure on how to do this.
I’m using mysql. this is how that table would look:
CREATE TABLE IF NOT EXISTS `pages` (
`id` int(11) NOT NULL auto_increment,
`parent` int(11) NOT NULL default '0',
`title` varchar(255) NOT NULL,
`deleted` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
the parent field keeps other page ID’s that will be used as parent when in the parent field.
Ok I worked out my own method, Please not I’m using kohana so I’m using the query builder of kohana:
This piece of code builds the array I want to use.
And this piece of code runs the url trough the array it gets stuck if a parent is wrong:
Note: The data you need to send to this function is: