Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manu/Navigation helper functions
#7
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 Wink

Or a stand-alone plugin that does nothing else but generate the xml file?

-Rob A>
Reply


Messages In This Thread
Manu/Navigation helper functions - by RobA - 2011-04-30, 05:08:18
Manu/Navigation helper functions - by mvlcek - 2011-04-30, 21:51:32
Manu/Navigation helper functions - by mvlcek - 2011-04-30, 21:59:26
Manu/Navigation helper functions - by RobA - 2011-05-01, 02:49:41
Manu/Navigation helper functions - by mvlcek - 2011-05-03, 00:11:53
Manu/Navigation helper functions - by RobA - 2011-05-03, 02:05:16
Manu/Navigation helper functions - by n00dles101 - 2011-05-03, 03:21:09
Manu/Navigation helper functions - by RobA - 2011-05-04, 00:08:06



Users browsing this thread: 1 Guest(s)