-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for empty regions directly in twig file for better performance #64
Comments
To give more detail <?php render function do not return the final output. This can be tested with facets module and facet option that do not render the facets when the facet source is not rendered. Laurent solution is the one we put on werkenvoor but may not be the best since this issue need investigation. Example, with facet we currently have this output in php on page where facet are not rendered: ' <drupal-render-placeholder callback="Drupal\\block\\BlockViewBuilder::lazyBuilder" arguments="0=category&1=full&2" token="3H-ATSLp_IKUKYnhOjRX3yjcYQjgLT6WOepB79hscJI"></drupal-render-placeholder>
' But when you render in twig it return '' Please note that solution implemented in Kiso also render region and their content multiples times (at least twice), that could lead to performances issues. |
Please investigate and provide me with the best solution or better than what we have now. In that case, I will add this issue in the Kiso (基礎) 2.7.3 milestone and I will implement this change request. |
Kiso should skip drupal generated HTML tags, like drupal-render-placeholder or drupal-entity (ideally, a rule to skip tags starting with "drupal-" would be the ideal). This would avoid false results as mentioned by GyD |
@GyD @rutiolma I'm not quite sure exactly what I'm supposed to do. Should I delete the following PHP code and only use kiso/includes/preprocess.page.inc Lines 12 to 17 in 4035ba0
kiso/includes/preprocess.utils.inc Lines 22 to 34 in 4035ba0
Could you please provide me with code example to implement in the |
@smillart , I did not add the So this patch is WIP. FYI, without this, my region is not outputed. Using Openfed |
There is a small typo in previous patch with Here's the updated patch. |
@lramarojaona I confirm you need to add Maybe using https://www.drupal.org/project/twig_real_content could be a good idea if bosa agree!? |
Ok, maybe we should create custom twig functions or filters for that: https://drupaljournal.com/article/drupal/creating-custom-twig-functions-and-filters-drupal |
Bugfix/#64: Replace old implementation to check empty regions with contrib module…
I don't fully agree with the solution. Removing this twig function will require an update to hundreds of sites, which is not really super simple. |
@rutiolma , good point, but it should be somehow marked as deprecated. |
IMHO we could keep the "has_region" function in Kiso and use it as we've been doing. It's way more clean to check for an empty region. If we mark it as deprecated, we should remove it for version 4.0.x and not before otherwise all existing projects will have to change their themes due to a minor release. |
I seems to be a safer approach for now. I know I'm overriding the has_region function in almost all my themes as it was not working properly (especially for regions with content such as facets). But does this approach solve anything performance wise? As this was the initial concern. @GyD what do you think? |
i have the same issue in one of the sites :/ after the upgrade to openfed 12 |
Yves brought my attention on a possible performance hit Kiso has by checking the regions content in a preprocess iso directly in twig.
We should remove the preprocess used to check the "has_navigation" and "has_complementary" and replace them with something like this in the page.html.twig file
The rest of the file doesn't need changes AFAIK.
The text was updated successfully, but these errors were encountered: