I have a custom backOffice template based closely on the default one, but with its own version of the includes/standard-description-form-fields.html template file. In that template file, I am calling a hook defined in a module, CustomFields, like this:
<hr>
{hook name="custom_fields.render_area"}
<hr>
On the Edit Product page, the two <hr>s are rendered but there's nothing between them. What's going on?
To get a better sense of what's happening, I went into Configuration > Hooks settings in the back office and clicked "Parse Template." This tells me that "YOUR TEMPLATE DOES NOT SUPPORT THIS HOOKS" even though the hook is right there in the template file. What does it mean for a template to "support" a hook? How can I make sure my backOffice template supports it?
Here's my config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/ thelia-1.0.xsd">
<hooks>
<hook id="custom_fields.hook" class="CustomFields\HookManager">
<tag name="hook.event_listener" event="custom_fields.render_area" method="onRenderArea" type="back">
</hook>
</hooks>
</config>
And my HookManager:
<?php
namespace CustomFields\Hook;
use Thelia\Core\Hook\BaseHook;
use Thelia\Core\Event\Hook\HookRenderEvent;
class HookManager extends BaseHook {
public function onRenderArea(HookRenderEvent $event) {
$event->add('<p>hi there</p>');
}
}
Finally, my class for the module itself:
<?php
namespace CustomFields;
use Thelia\Module\BaseModule;
use Thelia\Core\Template\TemplateDefinition;
class CustomFields extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'custom_fields';
public function getHooks() {
return [
[
'type' => TemplateDefinition::BACK_OFFICE,
'code' => 'custom_fields.render_area',
'title' => 'Render Custom Fields Area',
'description' => 'Render custom fields for a specific area in the admin',
'active' => true,
]
];
}
}
Last edited by ctamayo (16-03-2017 22:21:04)