I am working on a drupal website that has a theme installed to it.
I would like to set the Front/Home page of the website to a .html.twig template I have in a custom module I am busy working on.
How would I go about doing this? I have done some googling and it likes like the answer lies somewhere with page--front.html.twig, but I am not sure where to go from here.
Inside my themeFolder/templates there are page--front.html.twig & page.html.twig
I have tried creating my own page--front.html.twig and storing it inside myModule/templates but this did not help me.
Also, how would I go about applying .html.twig templates to different regions of my website?
Any advice would be greatly appreciated
Enable debug and check which template is using in front page. To enable the debug go to sites/default/development.services.yml
You will need to locate core/modules/system/templates/page.html.twig file. This is a base page template that you can extend. Copy this file into your theme templates folder (Look for tpl or templates folder - it depends on the theme you are using). Rename this file to page--front.html.twig and finally flush caches for the change to take effect. This can be done by executing drush cr in your terminal or in the UI (admin/config/development/performance).
If you are planning to work on custom layout for your homepage I would suggest creating a dedicated content type (for example Landing page) and setting up your layout with the help of Paragraphs module. This would allow you to avoid hardcoding functionality in you template files.
Related
I am beginner to Drupal-8, I don't know how to create custom template file for particular design for particular page.
For Example,
If I have created bellow pages in Drupal-8 and I want each of the page's custom template,
Like :
Home
About Us
Services
Contact Us
So for this how can I create custom template? Please anyone help me out to how can I achieve this?
Heyo!
So, Drupal page templating is managed through TWIG templates in your theme. You should first create a custom theme, which you can do following this guide:
https://www.drupal.org/docs/8/theming
Once you have a theme, you can create .twig files that will provide you with the means to control the html structure of the pages. Specific instructions are in this guide here:
https://www.drupal.org/docs/8/theming/twig/working-with-twig-templates
For example, creating a custom front page involves creating this file page--front.html.twig in your /templates folder. Different pages will require ovverides based on their name or node which is detailed in the above guide. However, it most likely is best practice to use a page.html.twig file to set a default style for the pages of your site and not have custom overrides for each node.
If you're new to twig, here's a link to twig tutorials. It's very simple and nice-and-easy to use!
https://symfonycasts.com/screencast/twig/basics
Drupal Website Design is Theme Based. There are plenty of themes to install in the Drupal.org. Seeing the particular theming documentation you can know how to customise your design.
You can look into some theming tutorials available in youtube also.
i want to convert my html website to the wordpress. But can you please talk me that how i can convert and connect the other pages with the main page???
I'm going to start from the point of view you already have Wordpress and are ready to start.
You can't take your existing HTML website and just add it to WP.
What you need to do is to build your own custom theme, that matches your current HTML files, using the already existing WP templates and files.
Best way is to duplicate an existing theme to play/manipulate so that you don't break WP. The last thing you want to do, having no experience, is to mess with and break the default theme and be unable to get it back again without a full re-install.
RE 'connect the other pages with the main page' WP allows you to have static pages and set them as your home page and/or anywhere else you want. With these pages you can also set up different templates within your theme if you need to.
Wordpress have all this help available here:
Wordpress creating static pages and custom templates
Its not really that simple. You should read about WP theming. Here's the start:
https://codex.wordpress.org/Theme_Development
Check codes from other themes to see how to output basics. Theming has a lot of parts, but to ouput custom html you will need these files:
style.css
functions.php
index.php
single.php
With those you should have an basic blog output with core WP functionality.
I'm new to Drupal. I have a page template that has a nav, header and footer. This works correctly for how I want most of my site, except for the login page that I would like to completely customize.
Is there a way to overwrite or ignore the overall site templating (perhaps by placing my login page template into a folder within the /templates directory?) in order to style that one page differently?
Thanks.
If you are looking out for customizing only the login page without its effect on anywhere in the site, you can use page--user--login.tpl.php to override it.
Basically you should find system template you want to override. It may be part of standard drupal installation but also part of some module. Copy it to your theme's templates directory and change the way you like. Clear the cache and drupal will re-scan your theme and start using templates you added instead of original one.
i'm wondering if it's possible to add a php file in your themes folder (wp-content/themes/classic) where the css file is, then link afterwards? Because i'm currently trying to add a register.php into my blog but i still need the header and everything else.
Yes. For example, if you want something like www.yourdomain.com/test follow this steps:
In your theme folder create a php file called page-test.php.
From your dashboard publish a page with the title Test(with no content at all).
Now, when you'll go to www.yourdomain.com/test you will se your page. And in page-test.php you can use all Wordpress functions such as get_header(), get_sidebar() etc.
Yes. What you want is to define a new "page" template, and then to create a new page in your wordpress using that template. Here's the WP documentation on that topic: http://codex.wordpress.org/Pages#Page_Templates
Alternatively, you don't have to place it in your theme folder; you can put it in the root wordpress folder and have it function outside of wordpress. Then you can change your theme to have a static link to that page, or link to it in some other manner. It would be more difficult to use the header/footer/sidebar template features, though.
I need to edit an invoice template in Drupal (both php template and css).
I've copied pasted the file in my theme folder, as I usually do to override for blocks and pages templates, but it didn't work.
This is the template customer.itpl.php inside Ubercart/uc_orders/templates folder.
How can I override it without hacking the ubercart module ?
thanks
This template is not the normal Drupal template. In order to change it, you should create a copy of the template in the same folder (Ubercart/uc_orders/templates) and make your changes. It will show up as an option in the settings page (/admin/store/settings/orders/edit) where you specify which template to use for showing the invoice.
devel_themer is good at providing template suggestions for you. Sometimes modules uses a special naming convention.
If that doesn't help you can add your own template suggestion in a preprocess function for the template. See this post on d.o for more info.
According to the ubercart docs you should be able to specify which template files you want to use.