Timeline for Pass Variable to Custom Block template file
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 6, 2020 at 5:14 | comment | added | therobyouknow | I found this to work. I had to study the number of bracket enclosures for the array in the tcdev_theme (hook_theme) function above and corrected mine as I had one too many arrays within arrays. Also, I'm curious to see that there is apparently more than one way to pass variables to twig, see also here drupal.stackexchange.com/questions/260469/… | |
Nov 30, 2016 at 12:31 | vote | accept | Yuseferi | ||
Nov 15, 2016 at 18:09 | history | edited | avpaderno♦ | CC BY-SA 3.0 |
improved spelling, grammar, and punctuation
|
Jun 3, 2016 at 12:19 | history | edited | 4uk4 | CC BY-SA 3.0 |
add references
|
Jun 3, 2016 at 6:29 | comment | added | 4uk4 |
If you still have the wrong block--sliderblock.html.twig , your block will never work. You have to remove this twig or put the correct content in it: cgit.drupalcode.org/drupal/tree/core/themes/stable/templates/…
|
|
Jun 3, 2016 at 6:24 | comment | added | Yuseferi |
I did, I create tcdev.html.twig but it ,clear cache but hit not rendered !!!
|
|
Jun 2, 2016 at 13:28 | comment | added | 4uk4 |
Your variables are not read by block--sliderblock.html.twig . This templates works with its own set of variables. (If you want to use this twig you would have to copy it from core or base theme and then you see what variables are inside). Your variables set in the render array of the build function will end up in tcdev.html.twig . Did you create this twig file?
|
|
Jun 2, 2016 at 13:20 | comment | added | Yuseferi |
I apply your code, rebuild the cache, but still read from block--sliderblock.html.twig and nothing passed to it . I enable debug info and debug info is <!-- END OUTPUT from 'themes/bootstrap/templates/block/block--system-branding-block.html.twig' <!-- FILE NAME SUGGESTIONS: x block--sliderblock.html.twig * block--slider-block.html.twig * block--tcdev.html.twig * block.html.twig --> <!-- BEGIN OUTPUT from 'themes/gttc_2016/templates/block--sliderblock.html.twig' --> <h2>Block-</h2>
|
|
Jun 2, 2016 at 12:19 | history | edited | 4uk4 | CC BY-SA 3.0 |
added 3 characters in body
|
Jun 2, 2016 at 11:51 | comment | added | 4uk4 | I tried to change your code to make things clearer, hope this works, didn't debug it. | |
Jun 2, 2016 at 11:48 | history | edited | 4uk4 | CC BY-SA 3.0 |
added 1117 characters in body
|
Jun 2, 2016 at 11:37 | comment | added | 4uk4 |
You want the content of the variables inside a block? Then this is not connected to a block template, because this is for the outside of the block. (block--sliderblock.html.twig rendered, because you used the name of a theme suggestion, this would render even if the block would be totally empty, you can try this)
|
|
Jun 2, 2016 at 10:57 | comment | added | Yuseferi |
But block--sliderblock.html.twig rendered, the problem is how pass my variable to it !!!? what is you suggest to me according to my code. ? tnx for your attention
|
|
Jun 2, 2016 at 9:09 | history | answered | 4uk4 | CC BY-SA 3.0 |