source: branches/1.1dev/docs/Nav.inc.php documentation.txt

Last change on this file was 1, checked in by scdev, 19 years ago

Initial import.

File size: 6.8 KB
Line 
1Navigation class. The following is just getting all the ideas I've had for this. Please append with your own ideas.
2
3include 'Nav.inc.php';
4$nav = new Nav();
5
6
7GOALS
8----------------------------------------------------------------
9To create an abstract interface for generating dynamic navigational elements, from knowing only the current location and a complete site heirarchy. It will have simple data input, data storage, and data output--it will not query a database, include files, or have ANY external requirements other than that basic data that can be given it. The designer/template integrator will use the output functions to generate nav elements. They will not need to worry about where the page info comes from. The programmer that configures the application with the nav class will make sure the data is input correctly. It will satify the use of the url_parser.inc.php file. It will do all that I was doing with $nav->addPage('title', '/url/url/url.php');
10
11                  +------------+ ---> Page <title>
12Site map & |      | abstract   | ---> Page header
13current    | ---> | data and   | ---> Breadcrumbs
14location   |      | functions  | ---> Sublinks
15                  +------------+ ---> Previous page
16                 
17                 
18                 
19$heir = array(
20    array(
21        'title' => 'Home',
22        'url'   => '/',
23        'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
24    ),
25    array(
26        'title' => '10 MarÑTh‰tre ÒspecialÓ',
27        'url'   => '/edition.php?edition_id=1',
28        'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
29    ),
30    array(
31        'title' => 'Sunshine and drugs',
32        'url'   => '/gallery.php?gallery_id=9',
33        'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
34    ),
35    array(
36        'title' => 'DSCN1053.JPG',
37        'url'   => '/gallery.php?image_mode=detail&image_number=1&gallery_id=9',
38        'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
39    ),
40);
41
42
43OUTPUT
44----------------------------------------------------------------
45Now, what is useful to generate? This is what you can help brainstorm.
46
47- current page identifier: Not yet sure what constitues a "page identifier".
48- page title: Riparian
49- page path: Sacramento River / Glossary Terms / riparian
50- breadcrumbs: same as title, but linked and maybe first item called 'home'.
51- sublinks: list of pages under current page
52- heirarchy links: list of pages under any page. (to get, for ex, all secondary nav links for the current path, to print in some special way.)
53- previous page: we can store ALL pages a user browses, and return to any of these.
54- entire site heirarcy, linked: for the 'sitemap' page.
55
56In all of these cases, the data is returned in one of two ways:
571. Raw data, usually an array or multidimentional array. Then formatting can be executed specific to a site.
582. Or each function can print the data in a generic fashion marked up in stylesheets.
59
60Here are the functions I propose for data output:
61
62$nav->getPageID()
63$nav->getTitle()
64$nav->getPath()
65$nav->getBreadcrumbs()
66$nav->getLinks()
67$nav->getHistory()
68$nav->getHeirarchy()
69
70$nav->printTitle()
71$nav->printTitlePath()
72$nav->printBreadcrumbs()
73$nav->printLinks()
74$nav->printHistory()
75$nav->printHeirarchy()
76
77Each function, if given no argument, will return/print data relevent to the current page. Otherwise each can be given $page_id, some kind of identifier for the current page (not sure what this is yet).
78
79
80
81INPUT
82----------------------------------------------------------------
83Maybe it can be put in "automatic mode" where you feed it the site map in a multidimentional array, and it figures out the current page from the URL.
84
85This is ideal if it can be done. Otherwise, in 'manual' mode, for more speciallized sites, the nav input can be generated dynamically, or manually for each page. The first two functions should be all that is necessary for automatic mode, but if you don't have the entire site heirarchy, the other functions must be used.
86
87$nav->setHeirarchy()
88$nav->setPageID()
89$nav->setPath()
90$nav->addCrumb()
91$nav->setFeature()
92$nav->hasFeature()
93$nav->setLinks()
94
95
96_________________________________________________________
97$nav->setHeirarchy()
98
99    To store the overall site architecture. Give it a multidimentional array like:
100    $heir = array(
101        'title' => 'Home',
102        'url'   => '/index.php',
103        'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
104        array(
105            'title' => 'Products',
106            'url'   => '/products/',
107            'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
108            array(
109                'title' => 'Plastic Bags',
110                'url'   => '/products/plastic_bags.php'
111                'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
112            ),
113            array(
114                'title' => 'Paper Bags',
115                'url'   => '/products/paper_bags.php'
116                'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
117            ),
118            array(
119                'title' => 'Vomit Bags',
120                'url'   => '/products/vomit_bags.php'
121                'features' => array('breadcrumbs'=>true, 'title'=>true, 'links'=>true),
122            )
123        ),
124    );
125    $nav->setHeirarchy($heir);
126
127_________________________________________________________
128$nav->setPageID()
129
130    If it can't figure out the current page from the url, use this value to set the current page (or override that detected by the url?) Still haven't figured out what constitues a "page identifier".
131
132    $nav->setPage('case_studies');
133
134_________________________________________________________
135$nav->setPath()
136
137    Store the path to the current page. Give it an array like:
138   
139    $path = array(
140        'Home' => '/',
141        'Catalog' => '/catalog/',
142        'Tools' => '/catalog/tools/',
143        'Hammer' => '/catalog/tools/hammer.php',
144    )
145    $nav->setPath($path);
146
147
148
149_________________________________________________________
150$nav->addCrumb()
151
152    Add another level to a path begun with setPath(). Use like:
153    $nav->addCrumb('Title', 'page_id');
154   
155    And if a page is at the end of the breadcrumbs it doens't need a url:
156    $nav->addCrumb('Add Comment');
157
158_________________________________________________________
159$nav->setFeature()
160
161    $nav->setFeature(array('breadcrumbs'=>true, 'title'=>false), 'page_id');
162
163_________________________________________________________
164$nav->hasFeature()
165
166    $nav->hasFeature('breadcrumbs');
167
168
169_________________________________________________________
170$nav->setLinks()
171
172    Store the sub links for the current page.
173   
174    $products = array(
175        'Hammers' => '/hammers.php',
176        'Screwdrivers' => '/screwdrivers.php',
177        'Saws' => '/saws.php',
178    )
179    $nav->setLinks($products);
180
181
182
183-Q
Note: See TracBrowser for help on using the repository browser.