This forum is for assistance with theme development.

How do I import a macro into a template?

Hello,

I created a macro that I want to use (hence import) into a template. I have looked at countless tutorials but none of them seem to help and my macro is not being imported.

This is my folder structure:

-/templates
  -/partials
    header.html.twig
  -/regions
    region--header.html.twig

I would like to import the 'header.html.twig' file (which contains the macro) into 'region--header.html.twig'.

This is the content of the 'header.html.twig' file (which I want to import):

Cannot compare twig field integer to 0, even if it is 0

I have an integer field that I am trying to get my template to display differently only if it contains "0". Though I cannot get it to output correctly.

{% if content.field_caves__max_level.0 != 0 %}
  {{ content.field_caves__max_level.0 }} Max
{% endif %}

I've tried numerous other combinations including

Edit view field with preprocess hook

I have the following drupal hook.

$variables['output'] before hook: 1111111

$variables['output'] after hook: (304)111-1111

$variables['output'] when view is rendered: 1111111

How to add page templates for content types in Drupal 8?

I'm using the "basic" skin

my type of content is called "apartments"

when a file is added page--apartamenty.html.twig it does not work this way.

I have drupal 8.7.3

I use this method and it does not work what I'm doing wrong?

https://befused.com/drupal/page-template-content-type

overide sub theme on specific page only

I understand that you can use template names to suggest different templates to use for different things such as
page, block, node ect

from a drupal theme (not from a module which defines a block ) is it possible to make a twig different template file render a specific block on a specific page only.

Lost most twig template/field suggestions

Not sure if this is a new issue, but I couldn't find anything with a search that matched.

I have twig debug set to true, and devel is running.

If I look at the source, there is only suggestions on blocks, not on content, or even the main html block. I don't have any sites running prior to 8.7 but I checked on 2 sites I own. One is plain bartik the other is bootstrap 3.

I can't see where to upload any screenshots. And I'm sure this doesn't make sense, but here is what it renders.

Pages

Subscribe with RSS Subscribe to RSS - Theme development