Views management
Views are design elements of pages and styles in which the simulators are integrated. They are composed of « Templates » and « Assets ».
« Templates » are (.twig) files that structure the page that is displayed.
« Assets » contain all the style elements (CSS files, JavaScript, images, fonts ...).
Managing (creating, modifying, deleting) views is only allowed for users with the « Manager », « Administrator » or « Super Administrator » role.
Click on the « Views » button on the menu bar
then on the « Create view » button in the left side menu
A form will then be displayed. It will be required to name the view (without space, special or accented characters) with the possibility to import two .zip files corresponding to the « Templates » and « Assets ».
If you do not have a « Templates » file and a « Assets » file, the view that’s is created will inherit the elements of the default view provided with G6K.
Click « Create » to save the view. The .zip files, if provided, will be unzipped and then the view will be displayed in the form of directories, with two tabs:
Figure 1 - Displaying the « Templates » of the « Demo » view
Displaying the « Assets » of the « Demo » view
If you want to export the « Templates » or the « Assets », select the corresponding tab and click on the button .
G6K then generates a zipped file that you can download.
Export (recommended) allows you to archive your views and re-import them into a new system if you change it.
There are several buttons that allow you to manage the « Templates » and « Assets ». Their functions are defined below.
If you want to add a subfolder or a file to a folder, click the « Add subfolder or file to ‘Name of folder’ » button:
A form will then be displayed to choose between:
In the « Templates » tab, only files with the .twig extension can be added, otherwise an error will be displayed.
For « Assets » there is no special extension or type.
Then press the « Submit » button.
Figure 3 – Form for adding a subfolder and displaying of the added subfolder
Figure 4 - Form for adding a file and displaying of the added file
To rename an element, simply press the « Rename ‘element’ » button :
A form will prompt you to indicate the new name of the element. You will need to press the « Submit » button to apply the renaming.
Figure 5 - Form to rename the element and displaying of the renamed element
To update a file, click the « Update this file » button :
An edit box will appear where you can edit the file.
Figure 6 - Editing interface (white background)
Once you have made your changes, click the « Save » button to save the file.
Once the filed saved, the « Save » button will change to the « Edit » button and you will not be able to edit the file until you press the « Edit » button.
Figure 7 - Uneditable interface, saved changes (greyish background)
To remove a folder, a subfolder or a file, click the « Remove this element » button :
A confirmation message will appear. If you are sure to delete this element, press « OK ».
The page will then be reloaded and the item you have deleted will no longer be displayed.
If you delete a folder that contains other elements, all its contents will be deleted.
If you want to delete a view, click the « Drop view » button.
A confirmation message will appear. If you are sure you want to delete the view, click « OK ».
The view will be deleted and will no longer be displayed in the « Views Management » menu:
This section describes how you must compose the templates of a view and the rules and constraints they must follow.
All templates you compose must inherit the base layout « EUREKAG6KBundle:base/layout:pagelayout.html.twig » supplied with G6K.
You must place the following line at the top of the template:
{% extends 'EUREKAG6KBundle:base/layout:pagelayout.html.twig' %}
The base layout performs the following functions:
These blocks are:
Note that the base layout does not add any visible content to the web page. It's in the « content » block that you have to put your elements such as page header, footer, menus, sidebar(s) and other contents. You must also add the simulation form, which you will do using a macro twig and variables provided by G6K.
Like the "Demo" view, it is advisable to define a layout specific to your view that will be responsible for displaying the different elements of the page except the simulation form and the elements specific to a simulator.
You will then define a template that will inherit the layout specific to the view and which will contain the simulation form and the elements specific to a simulator.
It's this last template that should be referenced in the definition of the simulation steps in the simulators. See Creating a simulator
Concretely, suppose your page has the following structure:
It's the layout that displays the part with gray background and positions the « content » block (part with white background) on the page.
It's the child template that feeds the « content » block where:
Label/Title of the simulator
Description of the simulator
Breadcrumb trail
Description of the current step
Location of the simulation form in the current step
Variables and macros that feed these elements are:
{{ step.simulator.label }}
{{ form.paragraphs(step.simulator.description|jscode) }}
{{ form.breadcrumb(_context) }}
{{ step.description }}
{{ form.draw(_context, 'form-horizontal', 'form-group', 'control-label', 'input-group', 'form-control', 'panel panel-default', 'panel-heading', 'panel-body') }}
To use these macros, they must be imported into the template:
{% import "EUREKAG6KBundle:base/macros:form.html.twig" as form %}
The available and useful macros are:
Available and useful variables are:
Figure 8 - « Demo » template illustrating the use of macros and variables