Project

General

Profile

« Previous | Next » 

Revision 859

Added by Matthias about 16 years ago

updated show_menu2 to version 4.7

View differences:

README.en.txt
1
show_menu2, version 4.6
1
show_menu2, version 4.7
2 2
=======================
3 3
A code snippet for the Website Baker CMS software. It provides a complete 
4 4
replacement for the builtin menu functions. All menu data is retrieved using 
......
6 6
can be generated with extensive customisation of the resulting HTML.
7 7

  
8 8

  
9

  
9 10
INSTALLATION
10 11
============
11 12
1. Download the latest version from http://code.jellycan.com/show_menu2/
......
17 18
   that you downloaded in step 1, and choose the "Install" button.
18 19
   
19 20
   
21
   
20 22
USING SHOW_MENU2
21 23
================
22 24
You need to modify the PHP files of your template to call show_menu2 where you 
......
45 47

  
46 48
See the "Output" section for details of exactly what classes are added to each 
47 49
element. More elaborate and different menu structures are able to be created by 
48
supplying parameters to the show_menu2 function call. For example, to show only 
49
menu items from the top level of the menu you use:
50
supplying different parameters to the show_menu2 function call. For example, 
51
to show only menu items from the top level of the menu you use:
50 52

  
51 53
    show_menu2(0, SM2_ROOT, SM2_START);
52 54
    
......
58 60
demonstration website at http://code.jellycan.com/sm2test/ for more examples. 
59 61

  
60 62

  
63

  
64
COMMON QUESTIONS
65
================
66

  
67
Q:  I'm not a programmer. Do you have simpler documentation? 
68
A:  Nup. This is it. Go hard. Gambarre.
69

  
70

  
71
Q:  How do I create a drop-down menu?
72
A:  This is unrelated to show_menu2. You need to change the template CSS code 
73
    to display the menu as a drop-down. Try the "allcss2" template from the WB
74
    addon repository. http://addons.websitebaker.org/pages/templates.php
75

  
76

  
77
Q:  Why does the menu disappear after I do a search on my multilingual WB site?
78
A:  You're missing some required lines in your template.
79

  
80
    1.  Log into WB administration, and go to Settings -> Show advanced settings 
81
        -> Search Settings -> Header Code and add the following input field 
82
        after the <form> open tag: 
83

  
84
        <input type="hidden" name="referrer" value="[REFERRER_ID]" />
85

  
86

  
87
    2.  In the index.php of your template, add the following input field 
88
        immediately following the search <form> open tag.
89

  
90
        <input type="hidden" name="referrer" value="<?php echo defined('REFERRER_ID')?REFERRER_ID:PAGE_ID;?>" />
91

  
92

  
93
Q:  Multilingual? That sounds cool. How do I do that?
94
A:  http://help.websitebaker.org/pages/en/advanced-docu.php
95

  
96

  
97
Q:  SM2 is generating a warning every time the page is accessed:
98
    "show_menu2 error: $aOptions is invalid. No flags from group 1 supplied!"
99
A:  You are passing the wrong values to the function. Have a closer look at the 
100
    parameters that you are passing. See the PARAMETERS section below for the 
101
    correct flag values to pass for the $aOptions parameter.
102

  
103

  
104

  
61 105
FUNCTION
62 106
========
63 107

  
......
67 111
        $aMenu          = 0,
68 112
        $aStart         = SM2_ROOT,
69 113
        $aMaxLevel      = SM2_CURR+1,
70
        $aFlags         = SM2_TRIM,
114
        $aOptions       = SM2_TRIM,
71 115
        $aItemOpen      = '[li][a][menu_title]</a>',
72 116
        $aItemClose     = '</li>',
73 117
        $aMenuOpen      = '[ul]',
......
77 121
        )
78 122

  
79 123
See the "Parameters" section for detailed descriptions of each parameter.
80
Note that every parameter from $aItemOpen onwards can be supplied as false
81
in order to get the default value, this allows (for example) a numbered list
82
to be used while still using the the default menu parameters for the items.
83
Note that all parameters up to $aFlags need to be explicitly supplied.
84
For example:
124
Ensure that you use each parameter correctly. Use the following rules:
85 125

  
86
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, false, '<ol>', '</ol>');
126
    $aMenu will be 0 for most people.
127
    
128
    $aStart must be either a page ID or a value starting with "SM2_".
129
    
130
    $aMaxLevel must be only values that start with "SM2_".
131
    
132
    $aOptions must be only values that start with "SM2_" (unless you are 
133
    in a very small minority of users).
134
    
135
    All other parameters are the HTML tag templates that will be 
136
    output for menus and menu items.
137
    
138
Note that every parameter from $aItemOpen can be supplied as false to get 
139
the default value.
87 140

  
88 141

  
142

  
89 143
OUTPUT
90 144
======
91 145
The menu is output differently depending on what parameters have been 
......
194 248
                      SM2_MAX       Starting level only (same as SM2_START)
195 249
                      SM2_MAX+1     Maximum of starting level and 1 level.
196 250

  
197
$aFlags   
251
$aOptions  
198 252
    Specify flags for different generation options for the menu. The flags
199 253
    may be combined together using bitwise OR (|). For example, to specify
200
    both TRIM and PRETTY you should use, SM2_TRIM|SM2_PRETTY.
254
    both TRIM and PRETTY you should use, (SM2_TRIM | SM2_PRETTY).
201 255

  
202 256
    GROUP 1
203 257
    -------
......
267 321
                    pages to fail validation. 
268 322
    SM2_NOESCAPE    Default behaviour. Exists only for backwards compatibility.                    
269 323

  
324
    This parameter also has an extended mode where an associative array of 
325
    options is supplied. See the EXTENDED OPTIONS section for details. 
326
    Most users will NOT need to use this.
270 327

  
271 328
$aItemOpen
272 329
    Format string to use for creating each individual menu item entry.
......
305 362
$aTopMenuOpen 
306 363
    Format string for the first menu. When set to false, it uses the same 
307 364
    format as $aMenuOpen.
308
        
309 365

  
310 366

  
367

  
368
EXTENDED OPTIONS
369
================
370
The $aOptions parameter is a dual mode parameter. For most users, only the
371
SM2_* flags will be sufficient. However, to access the extra options, it 
372
must be supplied as an associative array. Note that the SM2_* flags are
373
still required and must be supplied as 'flags'.
374

  
375
    'flags'     **REQUIRED** These are the flags described in PARAMETERS
376
                above for the $aOptions parameter. 
377

  
378
    'notrim'    Specify a number of levels relative to the menu level of 
379
                $aStart that will always be displayed. This will cause the
380
                SM2_TRIM flag to be ignored for these levels.
381
                        
382
To supply one of these options in addition to the flags, the option array 
383
should be created and passed as the $aOptions parameter:
384

  
385
    $options = array('flags' => (SM2_TRIM|...), 'notrim' => 1);
386
    show_menu2(0, SM2_ROOT, SM2_CURR+1, $options);
387
    
388
    
389
    
311 390
FORMAT STRINGS
312 391
==============
313 392
The following tags may be included in the format strings for $aItemOpen and 
......
335 414
[keywords]      Page keywords
336 415

  
337 416

  
417

  
338 418
CONDITIONAL FORMATTING
339 419
======================
340 420
The conditional formatting directive takes one of the following forms:
......
467 547
    // called once after finalize() if the SM2_NOOUTPUT flag is used
468 548
    function getOutput() { }
469 549
};
470

  
471

  
472

  

Also available in: Unified diff