:navigation-title: Templates .. _templates: ========= Templates ========= The study plan content element renders from one template and four partials, and its script finds every part it drives by a :html:`data-study-plan-*` attribute. Together those are the contract: replace any partial, with your own elements and your own class names, keep the attributes where this page puts them, and the filter, the highlighting, the semester accordion and the module dialogs keep working. .. contents:: :local: :depth: 1 .. _templates-where: Where they live =============== .. list-table:: :header-rows: 1 * - File - Renders * - :file:`Frontend/Default/Templates/AcademicStudyPlan.html` - The container, and the assets of :ref:`Skip the stylesheet or the script `. * - :file:`Frontend/Default/Partials/StudyPlan/Filter.html` - The category filter. * - :file:`Frontend/Default/Partials/StudyPlan/Semester.html` - One semester column, with its header and its modules. * - :file:`Frontend/Default/Partials/StudyPlan/Module.html` - One module, with its dialog trigger. * - :file:`Frontend/Default/Partials/StudyPlan/ModuleDialog.html` - The dialog of one module. All five sit below :file:`EXT:academic_study_plan/Resources/Private/`. Point the element at templates of your own with the three constants :typoscript:`plugin.tx_academicstudyplan.view.templateRootPath`, :typoscript:`.partialRootPath` and :typoscript:`.layoutRootPath`, or add a higher entry to :typoscript:`tt_content.academic_study_plan.partialRootPaths`. A path that holds one file replaces that one file; everything else keeps coming from the extension. .. _templates-arguments: What a partial is given ======================= Each partial receives exactly the variables it renders, so an override has an argument list it can rely on rather than whatever the template happened to have in scope. .. list-table:: :header-rows: 1 * - Partial - Arguments * - :file:`StudyPlan/Filter` - :html:`collapsible` - whether the site asked for the collapsible filter, see :ref:`Collapse the category filter `. * - :file:`StudyPlan/Semester` - :html:`semester` - the semester, with its :html:`modules`. * - :file:`StudyPlan/Module` - :html:`module` and the :html:`semester` it belongs to, the latter only for the label the dialog trigger announces. * - :file:`StudyPlan/ModuleDialog` - :html:`module`. The :html:`credit_points` of a semester and of a module are a number, not the value the database returns: printed as they are, they read "2.5", "30" and "0" rather than "2.50", "30.00" and "0.00". They render with a decimal point on every page language; format them in the override for a decimal comma. .. _templates-attributes: The data attributes =================== .. list-table:: :header-rows: 1 * - Attribute - Belongs on - What the script does with it * - :html:`data-study-plan` - The element that wraps the whole plan. - Starts one instance on it. The value is the uid of the content element; several plans on a page are told apart by the element itself, not by the value, so it may repeat. * - :html:`data-study-plan-filter` - The list the filter buttons go into. - Empties it and fills it with one button per category the rendered modules carry. * - :html:`data-study-plan-filter-template` - The single item inside that list. - Clones it per category, substituting :html:`category-id-placeholder`, :html:`category-color-placeholder` and :html:`category-label-placeholder`, and takes :html:`hidden` off every clone. * - :html:`data-study-plan-filter-collapsible` - The same list as :html:`data-study-plan-filter`, and only when the site switched the collapsible filter on. The extension renders it for you. - Hides the list and puts a toggle button in front of it, labelled from :html:`data-filter-label`. Without that label, or with no category in the filter, no toggle is inserted and the filter stays expanded. * - :html:`data-study-plan-semester` - The element that holds one semester with its modules. - Opens and closes it, and highlights it with its modules. * - :html:`data-study-plan-semester-header` - The header inside a semester. - Makes it the accordion control below 768 pixels and inert above it. * - :html:`data-study-plan-module` - One module inside a semester. - Reads its :html:`data-categories`, highlights it, levels its height on a wide viewport, and looks for its dialog and trigger inside it. * - :html:`data-study-plan-dialog-trigger` - The control that opens the dialog of a module, inside that module - or the module element itself, see below. - Opens the dialog of that module, by pointer and by keyboard. The dialog is the one named by :html:`data-dialog-id`, and the module's own when the trigger names none. * - :html:`data-study-plan-dialog` - The :html:`` of a module, inside that module. - Opens it as a modal and closes it again from the first :html:`