I try to use a custom twig template file without success
- copy modal-page-modal.html.twig from module template directory to your custom theme template directory and modify it.
- clear all caches
- clear all caches multiple times
- the template from my custom theme folder is never used
correct the module to load a custom template. It would be nice to have suggestions based on modal id
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | twig _debug.png | 74.28 KB | lucassc |
| #7 | after.png | 14.65 KB | lucassc |
| #7 | before.png | 14.28 KB | lucassc |
| #7 | test_module_module_content.txt | 2.47 KB | lucassc |
Issue fork modal_page-3283208
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
renatog commentedHello @realgiucas how are you?
Thank you so much for using the project
The template override functionality isn't implemented yet but I really thought about it. It should be a very cool feature!
So I'm converting to Feature Request ok?
P.s. We don't have so much time actually but if you want to contribute with that, any patches or merge-requests will be welcome
Comment #3
paulocsWorking on it.
Comment #5
paulocsJust created a MR for it. Please review.
Comment #6
lucasscComment #7
lucasscHi!
I applied MR !24 locally for 9.4.x and works fine.
Steps:
- created a custom module named "test_module";
- file "test_module.module" was created with hook_theme implementation (see "test_module_module_content.txt" attached);
- created "templates" folder inside the test_module;
- file "modal-page-modal.html.twig" was copied to new "templates" folder above;
- then I modified line 26 of "modal-page-modal.html.twig" from
<h4 id="{{ id_label }}" class="modal-title modal-page-title">{{ title }}</h4>to<h4 id="{{ id_label }}" class="modal-title modal-page-title">modifying something</h4>.Attaching screenshots of the results (see before.png and after.png).
I also enabled twig debug so I could see from where the output is coming and the given file names suggestions. (see twig _debug.png)
Comment #9
paulocsThank you!
Comment #10
renatog commentedAwesome. Thank you so much team
Adding the parent for the new release
Comment #11
renatog commentedCreated the ticket #3304196: Create a documentation explaining how to override the twig template where we can put the step-by-step