Closed Ainschy closed 8 months ago
I was debugging this for the past few minutes and this is because $this->headline is now of type Stringable and not empty in if-clauses anymore.
This is being caused in the last change: https://github.com/madeyourday/contao-rocksolid-custom-elements/blob/c69bf399c9fc6d87ab6114194a0a0ec16bf33466/src/Element/CustomElement.php#L301-L315
The question is if this should be fixed from your side @ausi or if every person using custom-elements would need to update their templates after updating to version 2.4.7.
We'd all either need to use <?php if ((string) $this->headline): ?>
or there should be a workaround.
I consider this critical since updates would lead to something that may output empty headlines like here:
<div class="ce_rsce_text col-m-6 text block">
<div class="inside">
<div class="c_headline">
<h1></h1>
</div>
<div class="c_text">…</div>
</div>
</div>
A possible solution would be using the ParseTemplateListener as it only renders html templates
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\Template;
#[AsHook('parseTemplate')]
class ParseTemplateListener
{
public function __invoke(Template $template): void
{
// Cast stringable to string (See #166)
$template->headline = (string) $template->headline;
}
}
@Ainschy can you please try if the latest dev-master
version fixes your issue?
Thanks it's look fine for me
Released as version 2.4.8
@Ainschy @zoglo thank you for the quick reporting/debugging/testing!
Contao 4.13.37 PHP8.2
Since 2.4.7 empty headlines are displayed in the frontend despite a query in the template.