Drupal 9 - Message and message statut system blocks are not displayed - drupal

Thanks for taking the time to read my question.
I have a problem adding the message and message status blocks in my content region using Drupal 9. I'm using a custom theme.
The blocks are simply not displayed. They are not even added to the DOM.
Here is my block configuration : https://imgur.com/gPvEq1Q (Sorry, it's in French. The two blocks are underlined in red)
And the configuration of each block : https://imgur.com/q3cBToL and https://imgur.com/hePdhHn (again, in French, but there are no restriction on page, role or type of content - it should appear everywhere)
I found these solutions online :
1 - https://www.drupal.org/forum/support/theme-development/2016-03-08/d8-any-reason-why-blocks-arent-renderingdisplaying
I tried uninstalling my theme, clearing the cache, reinstalling my theme but it doesn't work. The blocks did not appear in the Bartik theme either.
2 - https://www.drupal.org/forum/support/post-installation/2018-09-23/new-blocks-not-displaying
I tried adding a simple test block, it appears normally.
I tried displaying a test message using $this->messenger()->addMessage("test"); in a module to be sure there was something to display but with no success.
I'm not sure if it helps but here is my page.twig template :
<header aria-label="Site header" class="header" id="header" role="banner">
<div id='header-content'>
<div id="header-left">
{{ page.branding }}
{{ page.navigation }}
</div>
<div id='header-right'>
{{ page.user_menu }}
{{ page.search }}
</div>
</div>
</header>
<section class="main" id="main">
<main aria-label="Site main content" class="content" id="content" role="main">
{{ page.content }}
</main>
</section>
<footer aria-label="Site footer" class="footer" id="footer" role="contentinfo">
<div class="footer--top">
{{ page.footer_first }}
</div>
<div class="footer--bottom">
{{ page.footer_bottom }}
</div>
</footer>
Does any of you already encountered the problem ? Is there a solution ?
Thanks again !
EDIT
Here is the output from twig debug :
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--messages.html.twig
x block--system-messages-block.html.twig
* block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
<div data-drupal-messages-fallback class="hidden"></div><span data-big-pipe-placeholder-id="callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&args%5B0%5D&token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA"></span>
<!-- END OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
This suggests that the \Drupal::messenger()->addMessage(); does not output any message.
A strange thing I noticed testing with a FormBase class is that the Drupal\Core\Form\FormStateInterface::setErrorByName() method is working fine. A message is being displayed and the twig debug output becomes
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--cessoc-messages.html.twig
x block--system-messages-block.html.twig
* block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->
<div data-drupal-messages-fallback class="hidden"></div>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'status_messages' -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/status-messages.html.twig' -->
<div data-drupal-messages>
<div role="contentinfo" aria-label="Message d'erreur">
<div role="alert">
<h2 class="visually-hidden">Message d'erreur</h2>
The title must be at least 5 characters long.
</div>
</div>
</div>
<!-- END OUTPUT from 'core/modules/system/templates/status-messages.html.twig' -->
<!-- END OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' -->

My problem is solved !
Like Kien Nguyen suggested, this was an issue caused by the BigPipe module not filling the message block with the status messages.
Apparently, this was because my theme contained a jQuery.js file which was outdated. I deleted it and everything work fine now.

Related

Filter Ghost Homepage with specific tags

I use Ghost 3.0.2
I would like to limit first page (index.hbs) to display only posts with some tags.
I tryed without luck:
{{#foreach posts}}
{{#has tag="es"}}
{{> post}}
{{/has}}
{{/foreach}}
Current code is:
<!-- start content area -->
<div class="main-content-area">
<div class="container post-listing">
{{> loop}}
</div>
</div>

All custom fields are not working properly

I was working on a wordpress site and I have used Advanced Custom Fields plugin. I have also used Team Members plugin and after adding team members the shortcode that was generated I have put that on the Team custom field. But it was not reflecting. I have checked source code, the section was missing there
Also, I have tried using the same shortcode on the other fields, that worked but it's not working on the team field
Here I am sharing the screenshot. https://www.screencast.com/t/4tyIpfCz3N
<div class="container">
<div class="row text-center">
<div class="col">
<h2>Meet The Team</h2>
</div>
</div>
<div class="row">
<div class="col">
[tmm name="core-team"]
</div>
</div>
</div>
I have used the above code on the team field. On other fields it was working but it wasn't working only on that particular section
Any kind of help will be appreciatable
You need to get_field( 'team' ) in your template file, additionally you need to wrap this in do_shortcode(), as below:
echo do_shortcode( get_field( 'team' ) );
BUT there are lots of things wrong with how you are approaching this. You shouldn't be putting HTML in a WYSIWYG ACF field, they aren't built for that. Your HTML belongs in a template file. The point of ACF is to make things easier for end users to update and you have just complicated that by 1000% by forcing them to write HTML.
You don't even need to use your 'Team' ACF field for this section of what I presume is a single page website. Just put the below code into your page template (I'm assuming front-page.php). It will pull the team members directly from the Team plugin shortcode, bypassing ACF all together.
<h2>Core Team</h2>
<div class="container">
<div class="row">
<div class="col">
<?php echo do_shortcode( '[tmm name="8"]' ); ?>
</div>
</div>
</div>
Edited after code example by OP:
<div class="container">
<div class="row text-center">
<div class="col">
<h2>Meet The Team</h2>
</div>
</div>
<div class="row">
<div class="col">
<?php echo do_shortcode( '[tmm name="core-team"]' ); ?>
</div>
</div>
</div>

If/Else logic in Blaze causing authenticated user page flickers when navigating between pages in Meteor

I have this main layout
<!-- Wrapper-->
<div id="wrapper">
{{#if currentUser }}
<!-- Page wrapper -->
{{> topNavbar }}
<!-- Navigation -->
{{> navigation }}
<!-- Page wraper -->
<div id="page-wrapper" class="gray-bg">
<!-- Main view -->
{{> yield}}
</div>
<!-- End page wrapper-->
<!--{{> rightSidebar }}-->
{{else}}
{{> loginPage }}
{{/if}}
</div>
<!-- End wrapper-->
With the obvious purpose of displaying the login page if users are not logged-in. An unintended effect is when users navigate between certain pages/routes it can occasionally show the loginpage for a half second or two.
I am sure there is a way to do this with subscriptions, but just haven't gotten their in Meteor yet... was wondering if one of the ninjas out there that will look at this and scoff can pass a quick hint.
Thanks!
I have seen How to get rid of Meteor template flickers but I am hoping that there is a way to solve this without routing -- can I add the code to the main templates javascript file?
The problem is, there are not two states of logged in and not. There is also the in between state where the client is logging in. To account for that, there is a {{loggingIn}} helper which you could use as:
<!-- Wrapper-->
<div id="wrapper">
{{#if currentUser }}
<!-- Page wrapper -->
{{> topNavbar }}
<!-- Navigation -->
{{> navigation }}
<!-- Page wraper -->
<div id="page-wrapper" class="gray-bg">
<!-- Main view -->
{{> yield}}
</div>
<!-- End page wrapper-->
<!--{{> rightSidebar }}-->
{{else}}
{{#if loggingIn}}
loading...
{{else}}
{{> loginPage }}
{{/if}}
{{/if}}
</div>
<!-- End wrapper-->
Also on an unrelated note, you can use
{{!-- Spacebars comments do not get into the DOM --}}
instead of
<!-- This still gets into the DOM, but not rendered by the browser -->

Woocommerce's Cart page is being overwritten by my Page.php page in Wordpress

I'm having a little bit of a problem. My page.php seems to be overriding WooCommerce's cart page. The page is already created (generated by WooCommerce with the shortcode intact) named Cart.
I know that my page.php is overriding it, but I don't know how to stop that. Here is the code for my page.php page:
<?php
get_header();
if ( have_posts() ) {
//Work with us page
$workwithuspage = "work with us";
$pitch = "pitch an idea";
$cart = "cart";
if($workwithuspage == strtolower(get_the_title()))
{
//Page stuff here!
$image = wpse_get_images();
?>
</div>
<div class="hero">
<div class="container heroImage" style="background-image:url('<?php echo $image->guid;?>');">
<div class="col-md-7"></div>
<div class="col-md-5">
<div class="pageText">
Work with Us
</div>
<div class="subText">
<?php echo $image->post_content; ?>
</div>
</div>
</div>
</div>
<div class="bodyBg">
<div class="container">
<div class="col-md-6">
<div class="box-style">
<div class="box-header">
Got a comic idea and want it published?
</div>
<div class="box-text">
Tell us your desires, so we can slap it on a comic book and sell it for millions. Ya dig?
</div>
<div class="box-button-container">
<?php
$pitch = get_page_by_title('pitch an idea');
?>
<div class="button large">Pitch an Idea</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box-style">
<div class="box-header">
Want to work on one of our great titles?
</div>
<div class="box-text">
Tell us your desires, so we can slap it on a comic book and sell it for millions. Ya dig?
</div>
<div class="box-button-container">
<div class="button large">Find Jobs</div>
</div>
</div>
</div>
</div>
</div>
<div id="ourstandards">
<div class="coloroverlay">
<div class="container">
<div class="col-md-6">
<div class="pageHeaderText">
Our Standards
</div>
<div class="bodyTxt">
<p>
At On Target Network, we strive to promote consistency,
communication and passion in all areas of work and we expect the same of our artists.
</p>
<p>
We understand the nature of creators and seek to raise ourselves to higher and higher standards. To do that, we vet and
review series pitches with a carefully selected panel of writers and artists.
</p>
<br /><br />
<p>
Got questions? We'll be happy to help.
</p>
<div id="sendUsQ" class="secondaryBtn">
Send us your questions
</div>
</div>
</div>
<div class="col-md-6"></div>
</div>
</div>
</div>
<div class="container">
<?php
}
else if($pitch == strtolower(get_the_title()))
{
?>
</div>
<div id="pitchImg" class="hero">
<div class="container">
<div class="col-md-7"></div>
<div class="col-md-5">
<div class="pageText">
Pitch an Idea
</div>
<div class="subText">
<?php echo $image->post_content; ?>
</div>
</div>
</div>
</div>
<div class="bodyBg">
<div class="container">
<div class="col-md-12">
<div class="pageHeaderText dark">
Start your pitch here
</div>
</div>
<div class="col-md-9">
<?php
if ( isset($si_contact_form) ) {
echo $si_contact_form->si_contact_form_short_code( array( 'form' => '1' ) );
}
?>
</div>
</div>
</div>
<?php
}
}
get_footer();
?>
I have conditional ifs for pages I wanted to customize, but I fear in doing that, it has overridden (somehow) the cart page.
WooCommerce adds the cart using shortcodes; shortcodes get displayed as part of the page content. WP uses the the_content() function to display the content for a particular page or post. You've removed the_content() from your page template, therefore the cart doesn't display.
Looking at your page template, you've removed the_content() and inlined all your content directly into the template rather than fetching it from the database. This is atypical of a WP site in general, but I understand that sometimes a site starts off static and you just want to get it 'into' WP.
You're also using a bunch conditionals to display different chunks of content, which runs against the idea of using templates. My suggestion would be to create separate page templates for your 'pitch' and 'work with us' pages, and make page.php just a default page template that has the_content(). This way you have a generic template you can use for any page, including the cart page.
Check the codex for more info on creating custom page templates, but in a nutshell, you add a comment to the top of the file:
<?php
/*
Template Name: My Custom Page
*/
Then save your file in your theme folder. Common practice is to name it along the line of page-pitch.php so you can easily identify it. Then in the admin area you can assign the template to any page you want simply by selecting it from the drop down menu.
Splitting your different content into separate templates has a couple of benefits; namely you no longer have to use conditionals for checking the page titles (which can vary from install to install) and makes it much easier for you to debug things.

Drupal 7 - Where can I find templates for render() function?

While I was creating my custom template for node, I found out that Drupal adds extra html.
so I changed page.tpl.php like below to test
<div style='height:300px'>
<?php print render($page['content']); ?>
</div>
and then changed node.tpl.php to
hello
the output is:
<div style='height:300px'>
<div class="region region-content">
<div id="block-system-main" class="block block-system">
<div class="content">
hello </div>
</div>
</div>
</div>
where do all those extra tags come from?
I actually expected <div style='height:300px'>hello</div>
drupal_render() can be used to render so called renderable arrays. These are self-contained, they tell render() which theme function/template to use.
Try dpm($page['content']), that should then have a '#theme' key that contains that information.
Nice one with the dpm.
To print the h2 and body you could write something like this in the page.tpl.php.
<?php print render($page['content']['system_main']['nodes'][1]); ?></div> ?>

Resources