2011-05-03, 02:05:16
mvlcek Wrote:From my experience the best approach is to have a flat XML file with each entry looking like a page file without content.
On the first request for cached data the core would read the file and build a structure like this:
Code:$cached_data = array(
'url1' => array( 'url' => 'url1', 'parent' => 'parenturl1', ...,
'date' => <Unix timestamp, not string>,
'children' => array('childurl1', 'childurl2', ...)
'url2' => array(...),
...
'' => array('children' => array('toplevelurl1', 'toplevelurl2', ...))
);
(slug = url)
The order of the children entries should represent the order as defined by priority.
Additionally there is an "empty" entry with the toplevel pages.
This way you can
- easily access any page data by slug: $cached_data['slug']
- easily sort the entries by any metadata like publication date or name
- easily traverse from any page upwards to the toplevel page (bread crumbs):$url = 'url'; while ($url = $cached_data[$url]['parent']) do something;
- easily create a full menu by starting with $cached_data['']['children']
- easily create a child menu of any page by starting with $cached_data['pageurl']['children']
That looks simpler to use than an XML structure... Now, how do we get it in the core
Or a stand-alone plugin that does nothing else but generate the xml file?
-Rob A>