- Issue created by @msn5158
Also, using io ajax in blocks of ctools → and fieldblock → , they cannot load the block content.
- Status changed to Postponed: needs info
9 months ago 3:12pm 28 July 2024 - 🇮🇩Indonesia gausarts
Thank you.
> Twig and Token, they will become invalid...
Not sure, but worth a try. If using Views UI to create the block, please disable Cache options at the right hand side of Views UI. Most AJAX requests are required on demand as you can see by pressing F12, and inspect element, and scroll to the bottom near closing BODY tag. Any assets, JS or CSS, are requested directly, and never printed on the page due to the nature of dynamic request. It relies mostly in browsers cache mechanism instead.> blocks of ctools and fieldblock...
As noted at project requirements, IO block requires a block.html.twig which preserves container attributes and expects {{ content }} variables printed in a Twig template. It will fail if they are not there. You may want to check and verify those particular block templates yourself.Both are the current limitations we might consider to improve if any are doable.
Let me know your findings?
I use Twig and token in custom blocks (/admin/content/block), It get the path is /io/block by token
[current-page:url:path]
and twig{{ path('<current>') }}
, It treats /io/block as the current page.- 🇮🇩Indonesia gausarts
Yes, I am using this module and inline_formatter_field → .
What I mean is, it cannot retrieve data from the current page context if enable io ajax.
AJAX not enabled, available Twig in inline_formatter_field of custom block:
{{ drupal_title() }}
and{{ path('<current>') }}
, They work normally and meet expectations.But, if ajax enabled,
{{ drupal_title() }}
unable to obtain the current page title, and{{ path('<current>') }}
get the incorrect path (/io/block), not the current page path (/mypath/123).After testing, it wasn't can't use tokens and Twig, It only can't obtain contextual data for the current page.
When enabling AJAX:
The global token is working properly: such as
[site:name]
, but not include[current-page:title]
of current page.Twig is working normally: such as
{{ drupal_breadcrumb() }}
, but not include{{ drupal_title() }}
to get current page title.In addition, there's a question,
Edit in Node:
<h2>This is the Twig template from the node</h2> <h2>I can use {{ '{{ node.nid.value }} = ' ~ node.nid.value }}</h2> {{ dump() }}
Edit in custom block library:
<h2>This is the Twig template from custom block library</h2> <h2>I can use {{ '{{ block_content.id.value }} = ' ~ block_content.id.value }}</h2> <h2>But, I can't use {{ '{{ node.nid.value }} in custom block library (it will nothing print): ' ~ node.nid.value }}</h2> <h2>What should I do to achieve it like this</h2> {{ dump() }}
See the picture:
How do I use the node Twig template in a custom block library, How to import for use?
Thank you.
- 🇮🇩Indonesia gausarts
> only can't obtain contextual data for the current page.
You need to put the context, hence node, into thetoken_replace
arguments, as seen here:
https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/src/TwigTweakEx...Not sure if relevant, specific for title, there is a specific filter drupal_title like here:
https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/src/TwigTweakEx...
But I guess, using the first should be more contextual.