There are 2 ways that the navigation works:
- via ajx,
- via full page load (standard request),
The difference is that when navigating inside the project the content of the page is being loaded in the central container:
full page load is the standard navigation support. This is also required as for example user might want to open
given page in new tab so entire content of the page must be loaded, not only the central container.
Now how does this work?
Each action has one action which returns the content of the visited page:
Then there is additional method which renders the template:
$ajax_renderis responsible for deciding wether we are only reloading the container content or we are loading full page,
$skip_rewriting_twig_vars_to_jsis additional special variable used in case of handling actions such like update.
Templates are passing information about currently visited route to the JS and sometimes there is a need to skip rewriting such variables.
This is particullary needed when we modify a record via
update. In most of the cases the container is just fully reloaded with template
containing new state of current page - such reloading rely on the variables passed in the template.
There are 2 main/base templates of all the pages (this does not include dialogs):
Every page is extending from one of these templates, and the mentioned backend
$ajax_render variable is responsible
for deciding which template is being extended:
base.html.twig- used when reloading content via ajax,
templates/base.html.twig- used when loading content via standard request
Reloading page content is mostly handled by 2 methods:
AjaxEvents::loadModuleContentByUrl()- the result of called url must be an
AjaxResponsewith template param being set,
Ui::insertIntoMainContent()- inserts the content directly into the main container,
For example ajax calls for actions use directly
AjaxResponse is a global response sent
upon calling via ajax.
Project supports also reloading single menu nodes, however this is implemented only for example in
Files/Images and is triggered
upon creating new directory.
- menu nodes are defined in
- each reloadable menu node must have:
- data attribute:
Each menu node must be defined in separated file. The value of
data-menu-node-name must be a constant defined in :
Each new module node must be also added as constant in
src/Action/System/AppAction.php, additionally 2 arrays must be updated
with new node:
Each entry in
MENU_NODES_MODULES_NAMES_TO_TEMPLATES_MAP represents a twig template, so it's required that menu node template
has exactly the same name as in the patter. For example
MENU_NODE_MODULE_NAME_MY_FILES equals to path:
Most of the ajax calls are handled by