| | 1 | = Themes = |
| | 2 | [[TOC]] |
| | 3 | |
| | 4 | Sahana Eden supports custom Menus as part of it's overall [DeveloperGuidelines/Templates Templates] system. |
| | 5 | |
| | 6 | This allows customisation of: |
| | 7 | * Menu content |
| | 8 | * Menu layout |
| | 9 | |
| | 10 | NOTE: This is still a work-in-progress: not everything here is ready yet & the details may change! |
| | 11 | |
| | 12 | == Default Menus == |
| | 13 | By default these files are used: |
| | 14 | * {{{/modules/eden/menus.py}}} |
| | 15 | * {{{/modules/eden/layouts.py}}} |
| | 16 | |
| | 17 | These both build on the core functionality in: |
| | 18 | * {{{/modules/s3/s3navigation.py}}} |
| | 19 | |
| | 20 | This core functionality ensures that menu items only appear of the appropriate moduels are enaled & if the user has the relevant permissions to access the resource. |
| | 21 | |
| | 22 | There are 2 menus by default: |
| | 23 | * S3MainMenu |
| | 24 | * defaults to a link to the homepage of each enabled module, plus a section for Logging-in & selection of Language |
| | 25 | * defaults to being rendered horizontally across the top of the page |
| | 26 | * S3OptionsMenu |
| | 27 | * a separate menu for each application |
| | 28 | * defaults to being rendered vertically on the left of the page |
| | 29 | |
| | 30 | == Custom Menu Content == |
| | 31 | In order to customise the content of the menus, you should create a template folder, if you don't already have one, and ensure there is an empty __init__.py file inside: |
| | 32 | {{{ |
| | 33 | /private/templates/<template>/__init__.py |
| | 34 | }}} |
| | 35 | |
| | 36 | You should then copy the example file from the 'default' template folder to: |
| | 37 | {{{ |
| | 38 | /private/templates/<template>/menus.py |
| | 39 | }}} |
| | 40 | |
| | 41 | You can modify the labels (which are automatically translated unless you specifically set {{{translate=False}}} on an item), which items show, and in what order, and under which conditions. |
| | 42 | |
| | 43 | Note: For high performance, all conditional checks should be constructed as lambdas so they are called only when that menu is rendered not on every request. |
| | 44 | |
| | 45 | == Custom Menu Layouts == |
| | 46 | If you wish to go further than simply customising the content, but rather change the look & feel or add more different sorts of menu, then you need to also copy one of the example layouts.py files to: |
| | 47 | {{{ |
| | 48 | /private/templates/<template>/layouts.py |
| | 49 | }}} |
| | 50 | |
| | 51 | This allows you to subclass the normal layouts, S3MainMenuLayout and S3OptionsMenuLayout, so that you can alter their HTML structure, add custom classes, etc |
| | 52 | |
| | 53 | You can also add completely new classes & make use of these for menus in your menus.py. |
| | 54 | |
| | 55 | == See Also == |
| | 56 | * [DeveloperGuidelines/Templates Templates] |
| | 57 | * [DeveloperGuidelines/Themes Themes] |
| | 58 | * [DeveloperGuidelines/CustomPages Custom Pages] |
| | 59 | |