The following is a style guide for interface design in Koha (creating and maintaining templates).
It addresses both 'Koha Interface Design Theory' and technical questions of how to mark up your HTML code using the 'Koha Conventions'.
Jenifer Tidwell Designing Interfaces
Krug, Don't make me think!
Just a few definitions so we have some jargon with which to discuss interface design principles:
Koha's template system offers a rich environment to make major or minor changes to the look and feel of your Koha system. Understanding the various parts of the system is key to being effective in template creation, modification and maintenance. Templates in Koha are stored in:
koha/koha-tmpl/<interface>-tmpl/<theme>/<language>/
So, for example, the 'prog' templates for the 'staff client' in English language would be located:
koha/koha-tmpl/intranet-tmpl/prog/en/
The modules directory contains the templates parsed by HTML::Template for every module:
<template><language>/modules/
The includes directory stores all includes parsed by HTML::Template
<theme><language>/includes/
Notable, are the new conventions for representing css, js, and xslt files as includes (useful if you need to pass TMPL_VARs to one of these files)
<theme><language>/includes/*.css.inc <theme><language>/includes/*.js.inc <theme><language>/includes/*.xsl.inc
Several koha users have added support for 'overrides'. The recommended convention is to place overides in the overrides/
CSS, JavaScript, XSL and images (anything not parsed by HTML::Template and available in the document root) can be found in:
<theme><language>/css <theme><language>/js <theme><language>/xsl <theme>/img
External libraries, such as yui, the 'calendar' code, ext-js, etc, are stored in:
<theme>/lib
TODO: split up themelang into 'theme' and 'lang' variables to distinguish between theme-level and lang-level elements.
Every page contains a standard set of markup elements:
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --> <title>Page Title</title> <!-- TMPL_INCLUDE NAME="doc-head-close.inc" --> <script type="javascript">Optional embedded javascript</script> <link rel="stylesheet" type="text/css" href="Optional page-specific styles" /> </head> <body> <!-- TMPL_INCLUDE NAME="header.inc" --> (contains top-level navigation, login info, help) < resident search box > (optional. ex: check out to, search patrons, catalog search, etc) < breadcrumb navigation > (always begins with "Home ›") < body layout scheme (YUI Grids divs) > Main body content < /body layout scheme > <!-- TMPL_INCLUDE NAME="mainmenu.inc" --> (contains left-hand navigation, facets, or section-specific menu) <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
This code block illustrates the way that the cascade of CSS (and JavaScript) is applied in Koha
<!-- CSS --> <!-- LAYOUT --> <libs> staff-global.css <module> <page> <widgets> <!-- COLOR --> staff-colors.css <!-- JAVASCRIPT --> <libs> staff-global.js <module> <page> <widgets>
Global Search: circ (active), catalog
Circ-Subnav: (everywhere in this module)
Patron-Subnav: (only on patron-specific pages)
Toolbar:
Global Search: patrons (active), catalog, circ
Subnav:
Toolbar:
Global Search: none
Subnav:
Toolbar:
Global Search: cataloging search (active), authorities (maybe), serials (maybe)
Subnav:
Toolbar:
Global Search: vendors (active), order history
Subnav:
Toolbar:
Global Search: catalog (active), circ
Subnav:
Toolbar:
Global Search: tool-specific (active), catalog, circ
Subnav:
Toolbar:
Global Search: admin-specific (active, catalog, circ
Subnav:
Toolbar:
Use semantically meaningful XHTML-compliant markup wherever possible:
For block elements, use <div>, not <p>.
For inline elements, use <span>.
Use <li> for all lists of items (navigation, subnav, etc.)
Use tables for tabular data.
Use CSS, not <p> and <br /> to create visual whitespace.
Explicitly state <form> action.
Don't use the fieldset tag inappropriately. The fieldset tag is used to group related form elements together with a caption and labels. The caption is created using the legend tag. Don't use the fieldset tag for anything other than form elements.
Don't use the label tag for non-form content. Label tags should reference a specific <input> using this method: <label for=“input-id-attribute”>Label text:</label>. This method allows the user to click the label to place cursor focus in the input field.
Don't embed CSS (via <link> or <style>) anywhere but in the <head>.
Don't use tables for layout purposes, adhere to tableless design except in the case of tabular data.
Avoid embedded Javascript controls via methods like onclick, onfocus, onload, onblur, etc. Events should be established using a javascript library like jquery or YUI based on element ID, class, etc.
If you must use a method like onlick or onfocus, make sure the attribute is in all-lowercase.
The global stylesheet defines global elements: site title, login info, branch, page color, some table styles for border collapse, padding for table cells and headers, font weight bold for table headers
It also includes styles for global widgets such as:
Breadcrumbs are globally present, but defined at the page level. Their style is specified in the global stylesheet and they appear directly below the global navigation
Global navigation contains the following links: 'Circulation', 'Patrons', 'Catalog', 'More'. Clicking on 'More' reveals a JavaScript drop-down that contains the rest of the modules. 'More' degrades as a link to the mainpage, where a full list of modules is available.
Two side-by-side panels. In one, list of items that can be selected or 'clicked', in the other, the content associated with that item.
Examples:
Iconic palette inside of or next to a panel; user clicks on the palette buttons to perform actions on the panel
Examples:
A pattern is a combination of idioms and widgets, as well as definitions for things like the number of columns in a page and their size. The goal with defining patterns is to identify all of the similar paradigms within Koha that should share markup and stylesheet conventions.
Examples:
Examples:
Page-defined toolbar for adding new rows, editing rows, deleting rows
Filter at top of page:
When results come back, original filter still displays at top of page with the term or phrase entered.
Inside the table:
Examples:
Note:
Potential Types of Fields:
Notes on the Patron Entry Form:
* Salutation should be an authorized value like 'Road Type' * Move Flags and Messages to own form * Use format date jquery instead of calendar (calendar is too hard to use) (maybe use server-side?), say format of date in tooltip * We seem to need two patron entry forms: 'quick add' for libraries like NPL that do member entry on circ desk. This form only has: * Name * PatronCatagory * Username/password * Cardnumber Offer the user the option to complete in the long add Koha 'long add': Personal Information |-> Identity (Name, DOB, etc.) |-> Type Contact Information |-> Address -> Main, Alternate |-> Contact -> phone, email, sms, etc.
Library information
* road types * overduerules.pl (should be in admin, should warn if no letter defined) * letters.pl add letter (should be in admin, rename) * news.pl add news * import.pl (belongs in cataloging, upload form, needs enhancements!!) * export.pl (download form) * edit system preferences * z3950 servers (add) * printers (add)
* label
* holidays.pl (has a filter, chart with legend)
all frameworks (need breadcrumbs at each level) * authtypes.pl (main page)
fines and circulation rules
koha2marclinks.pl ? (should be able to view, but not edit?)
catalog maintenance (search catalog, reservoir, other targets)
authorities detail page, detail page for records, etc.
acquisitions home
need a back button
* about
search results page (facets, results)
system preferences
default MARC editor
There are ways to trigger certain CSS and JavaScript includes by adding their locations to a given perl script. Alternatively, they can be directly included in the template itself (which may be a more readable method).
In each script, there's a section that looks like the following:
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "about.tmpl", query => $query, type => "intranet", authnotrequired => 0, flagsrequired => { parameters => 1 }, debug => 1,
To use style and script controls on a given page, add the following as needed to the perl script after the above:
# looks in <themelang>/ css_libs => [ { lib => 'test/path1/lib.css' }, { lib => 'test/path2/lib.css' }, ], # looks in <themelang>/css/modules/ css_module => 'css/modules/<module>.css', # looks in <themelang>/css/pages/ css_page => '<page>.css', # looks in <themelang>/ css_widgets => [ { widget => 'test/path1/widget.css' }, { widget => 'test/path1/widget.css' }, ], # looks in <themelang>/ js_libs => [ { lib => 'test/path1/lib.js' }, { lib => 'test/path2/lib.js' }, ], # looks in <themelang>/js/modules/ js_module => '<module>.js', # looks in <themelang>/js/pages/ js_page => '<page>.js', # looks in <themelang>/ js_widgets => [ { widget => 'test/path1/widget.js' }, { widget => 'test/path2/widget.js' }, ],
You can then add the relevant js or css files to the appropriate location for use when the page is loaded. Javascript and CSS can also be linked or embedded in the page <head> by adding it directly to the template. This method should be chosen if the script must reference HTML::Template-processed data.