PyroCMS v0.9.7.4 - an open-source modular general purpose CMS |
[eluser]Turv[/eluser]
Okay, Well i hit a stump... I've got a solution that will allow an unlimited sub-page structure so you can have pages such as /parent/primary/secondary/sub-page/ It works by passing an array of URI Segments to the page function, This receives an array such as Code: Array With sub-page being the targetting page for content, I store this slug in a variable, remove it from the array. The last item in the array (Secondary) is then the parent of this page. So i query the database to get the ID (Parent ID) for the Secondary page. If there are more than one result, I perform the final query where i find a row in the database where the slug is 'sub-page' and the parent id is whatever the id of secondary is. This means you can have multiple 'sub-page' slugs. However...The problem i have is that if i have pages where the last parts are identical (unlikley to happen?) it causes problems. Such as, If i have another page such as... Code: Array Then with the last two parts (secondary/sub-page) being the same it fails. What i need is a way to recursively call getIdBySlug passing a new parent slug until i get a reslt with only one row. This is the code i have... Pages Controller, _remap function Change: If a sub page (of any kind) exists then pass on the uri segment array, otherwise just pass the first segment, call page function directly Code: function _remap() Page Controller, Pages function Change: Restored back to the original, No changes needed in this function anymore Pages Model, getBySlug function Code: public function getBySlug($slug = '', $lang = NULL) Pages Model, getIdBySlug function Code: public function getIdBySlug($parent = null, $slug = null) { So basically, what i did in my test installation was create a number of child pages so i had two urls as below /primary/sub-page/sub-sub-page/ /test-page/sub-page/sub-sub-page/ When going to /test-page/sub-page/sub-sub-page/ i received the content for /primary/sub-page/sub-sub-page/ because in my getIdBySlug function, when doing the additional check i return the id as soon as i find a match. What i need to do instead is like a recursive function using the rest of the uri array to....I don't know, have a look see if you can figure anything out. This at the moment...seems to work perfectly for any url as long as there are not two segments of the same name as per the above example |
Welcome Guest, Not a member yet? Register Sign In |