html.twig, so that Drupal can recognise and use the file. The basic naming convention for a twig template is to end the file name in. For example any node template files could sit in a folder called node. The twig templates go inside a folder called templates inside theme folder, for ease and good practice you can also split up the different types of templates into folders. Twig is a very established and quite popular templating engine, allowing for easier adoption and sharing some of maintenance/ improvement load onto a wider community. Twig was one of the other major changes that was brought in in Drupal 8, which saw the switching of the theme engine from PHP Template to Twig. To make our pages output the markup/ content that we want, we need to create twig templates in our theme. ![]() Navigation_collapsible: Navigation (Collapsible) info.yml that we created for this blog post. There are lots of other elements that you can add, have a look at. Drupal uses regions to allow developers to structure the pages of the site. The base theme key was optional in Drupal 8 but required in Drupal 9.įinally we are going to setup a number of regions that we can use in our theme for adding blocks etc too. Next we set if the theme is sub theme of any one of the base themes, which can be one of the core themes or a contrib theme, equally you can set this key to false. ![]() Next thing to set is a library, this will bring in our css and js files, that we will setup later on, so don't worry too much about this just now, we can also attach a library to pages via other means, but we won't get into that in this blog post. We also specify the core_version_requirement, so that we can enable the theme in Drupal 9, the core element is not needed if you don't want the theme to be installed on Drupal versions less than 8.7.7. info.yml file for a module, in the sense that we specify a name, optional description and a package, we also need to set the type, but whereas we specified module as a the type, we need to specify theme as the type for this, so that Drupal knows that we are adding a theme. The file starts off in a similar manner as a. info.yml, so in the case of this blog post, the file we have is called custom_. Just like creating a module, we need to tell Drupal that we have added a new theme, so we need to create a file inside our theme folder that we just created above, the file name should be in the format of.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |