How to overwrite form.html.twig using a custom module in drupal 9 - templates

I have created a custom form in a custom module but No matter what I do, the form is still is using core/themes/classy/templates/form/form.html.twig as the template. i've tried everything (that I can find) on the web but still no way to have own template applied. Please help!
Tried everything google can find me.
Just need my custom template to be applied instead of the default one.
My only requirement is for the module to contain its own theme templates and not rely on a specific theme.

Having tried everything I could find, I resulted to overwriting the template in a new theme rather than in the module. I wanted something else, but better than continuing to waste time. I hope this helps someone else.

Related

I am having serious problems customizing my views template to displayblog entries in drupal 7

I am having serious problems customizing my views template to displayblog entries in drupal 7.
please anyone with knowledge of what can help me please reply. i have gone through a couple of drupal documentations but no luck. my field.tpl.php seem to be the only template that actually affect my displays even though i have views-view-field.tpl.php, views-view--blog.tpl.php in the template .
In the view settings, under format, show, make sure you have fields selected, not content.
Under advanced, theme, click information to see which template files are being used, and click rescan if necessary.
If you have created or edited a view, please check under FORMAT section this should be Show:Fields and under Advanced section look for Theme:Information and click onto this, there will be a popup with all possible templates for the display plugin and for the style plugins. All field tpl will be available here those are exists in views fields, you can find your own and use as per your requirement.
When you edit your view open "Advanced" section on the right (collapsed by default) and click on "Information" from "Theme: Information" (last option in that section). There you can see what templates are used (bolded ones) and what could be used instead. You can even click on template description at the beginning of the line, and code will be displayed. Grab that code (copy) and create new template file with one of offered names. Place that template file in your theme and clear the cache. Now you can modify template by your needs.
Also, you even don't have to use all that hierarchy (even that's desirable), but you can i.e. find the template file that are looping over the rows and inside that loop put your html, so lower rank templates won't be included (i.e. template that iterates over fields or even over rows) . Again not so clear solution, but it works for me. I prefer having less template files and I know that nobody will work on that theme except me.

What is the best way to fin and use a template in cakephp 3

i'm new in cakephp and I have started with version 3. I want to build a beautifull app and because I'm not good in design, I would really like to use a free template or buy one that I can use within cakephp.
So, I would really appreciate all your propositions and ideas or best practises. The easy way will be the best because I don't have a lot of time with this project. Thank you in advance.
If you don't have a lot of time like you mentioned, the easiest way to go ahead and get started is to paste a lot of the code in your default.ctp layout inside of src/Template/Layout/default.ctp.
You'll notice there are some lines of PHP already in there that are relevant to fetching blocks of css, meta tags, and other bits of code that could potentially exist throughout your project.
Find the main layout of the theme your trying to use - the one that will be consistent across most of the pages. That's the one you'll use for default.ctp. Compare what's already in default.ctp and make the comparable adjustments around the HTML in that document while keeping the important lines of PHP there as well.
For other important pages like a login or registration page, just create a new document for those, like 'login.ctp', then inside the function that loads the page (maybe 'login' inside of UsersController'), change the default layout with this line of code:
$this->viewBuilder()->layout('login'); // without the .ctp ending
This way you can create one-off layouts that don't really match any other page.

Animating template changes in Meteor

I have looked, but am unable to find anything which makes me think I'm approaching this the wrong way.
When I update the content in a template, or display a new template, I want to animate the transition. Currently the content switches but I'd like to be able to use Greensock or similar to perform the change. I have Greensock working on elements fine, but not on templates.
I'd show code but I'm not sure where to begin. I'll update when I've at least made a start.
Cheers.
You can google about undocumented Meteor _uihooks used for example here:
https://atmospherejs.com/percolate/momentum
https://atmospherejs.com/percolate/momentum-iron-router

Overriding templates when using Grappelli

I'm using Grappelli with Django. When I follow the procedure as outlined in the Django docs to override a specific template for a specific model, it appears that Django (or Grappelli??) are struggling to render the template correctly.
I have copied the change_form.html file to the templates directory with the following subpath:
admin/properties/Calendar
where properties is the name of the app and Calendar is the name of the model for which I want to override the change form. Now the following appears
At least two things are not rendered correctly:
The breadcrumb bar is much thinner and the crumbs are tightly aligned with the left border of the bar.
The link for the history of changes is in the wrong place (it appears on the left), has the wrong style (no rounded edges) and appears twice.
I double checked that the correct template file is used by Django, so the mechanism as documented works albeit with the above described flaws. When I rename the duplicated template file or delete it from my app, everything looks fine again.
Before I dive into this, I was hoping someone could hint at what is going wrong here. All not overridden templates seem to work just fine.
From what I read I suspect you copy the default admin change_form.html template and not the grapelli version, found at grappelli/templates/admin/change_form.html.
If you want to override a grapelli template, then you should use that as source!

Combining multiple Django Views/Templates

I am working on a website. On the Homepage, I want to show the posts in the center and show famous tags on the right side of the page. Now, posts and tags are two different apps and their views/tempaltes are calculated/generated in two separate functions.
How can I show what I want on my Homepage keeping my mind that its two different views being called. As far as I understand, I can only call a single view to show my homepage.
This must be possible but I am unable to understand this. Any help will be much appreciated.
I think you need to create a custom template tag that in this case called: Inclusion tags
You can look into writing a custom template tag for the tags. That way the tag logic can stay in the right application.
It depends how these different apps render the templates. If they just render the template without extending from a base template you could simply use AJAX to load all the content into your homepage.
If not, then there is no other way than writing a custom solution for this. This could be an extension to your views, a custom template tag as already mentioned or something else according to what exactly you need.