BrendonKoz Posted October 29, 2021 Share Posted October 29, 2021 I'm having a strange issue that hopefully some more seasoned PW users would have some insight on. I have enabled the Functions API, Markup Regions, and am appending a primary template file (of which I currently only have one markup region defined). All secondary major page template files insert their content into that markup region. In one particular page template file, I am attempting to render a field template ("callout.php") if it has content. For whatever reason, it is not rendering. If I insert a <?php die(); ?> within the field template, the output from the template is visible. If I move that <?php die(); ?> statement to outside the IF/ELSE block that tests whether the field has a value, the content from the field's template is no longer rendered. Oddly enough, the RepeaterMatrix field's template immediately preceeding this particular field's template is rendered. Within /site/templates/policy.php, the following excerpt (for the callout field) is the troublesome code. <?php namespace Processwire; ?> [...] <section class="main-content" id="content-skip"> <h1><?= page()->title; ?></h1> <span class="policy-status">Last updated: Month, Year</span> <section class="policy-document"> <?= page()->render('content_body'); ?> </section> <?php if (page()->callout) { page()->render('callout'); } ?> </section> Within /site/templates/fields/callout.php I have the following: <?php namespace Processwire; ?> <div class="card border-<?= $value->callout_type->value; ?> mb-3 card-note"> <div class="card-header"></div> <div class="card-body"> <div class="card-text"><?= $value->content; ?></div> </div> </div> Regardless of whether the variables are correct or not (based on the die() statements, they are), I would expect the HTML to be rendered. Like stated, if I place a <?php die(); ?> statement inside (at the end) of the callout.php template file, I can see the expected PHP/HTML get output. If I instead place it after the IF statement in the policy.php template file, the HTML output from the callout.php file does not exist. I'm not sure if it's my mixing of output methods during implementation, or something else entirely. I tried passing an $options array value to prevent caching through page()->render('callout', ['allowCache' => false]); to see if it would make a difference. It did not. Link to comment Share on other sites More sharing options...
Zeka Posted October 29, 2021 Share Posted October 29, 2021 Hi @BrendonKoz I have never used markup regions, so no help here, but I see that you use Processwire instead of ProcessWire namespace and there is debug section in the docs, so maybe it could help to find what is going on https://processwire.com/docs/front-end/output/markup-regions/#debugging-regions 1 Link to comment Share on other sites More sharing options...
BrendonKoz Posted October 29, 2021 Author Share Posted October 29, 2021 After your suggestion (thank you!) I did try the <!--PW-REGION-DEBUG--> tool from the primary template file (auto-append from site config), but unfortunately that seemed to render exactly what was expected: the one switch that was made indeed got switched. I made one error in my description of this problem, however: A die() statement inside the IF statement of the policy.php file does not render the content. The content is rendered if a die() statement is made within the callout.php field template, however. Link to comment Share on other sites More sharing options...
BitPoet Posted October 31, 2021 Share Posted October 31, 2021 I'd say it's just a question of a missing "echo" in front of page()->render('callout'); 1 1 Link to comment Share on other sites More sharing options...
BrendonKoz Posted November 1, 2021 Author Share Posted November 1, 2021 Wow. That's embarrassing. You are 100% correct. ?♂️ Can't believe I didn't notice that after staring at it over multiple days. Thank you!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now